mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-25 00:00:26 +08:00
Remove Note.addImageSync
We can just always use the async version.
This commit is contained in:
@ -508,23 +508,6 @@ class Note with NotesNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addImageSync(String filePath) async {
|
||||
var file = File(filePath);
|
||||
var absImagePath = _buildImagePath(file);
|
||||
file.copySync(absImagePath);
|
||||
|
||||
var relativeImagePath = p.relative(absImagePath, from: parent.folderPath);
|
||||
if (!relativeImagePath.startsWith('.')) {
|
||||
relativeImagePath = './$relativeImagePath';
|
||||
}
|
||||
var imageMarkdown = "\n";
|
||||
if (body.isEmpty) {
|
||||
body = imageMarkdown;
|
||||
} else {
|
||||
body = "$body\n$imageMarkdown";
|
||||
}
|
||||
}
|
||||
|
||||
String _buildImagePath(File file) {
|
||||
String baseFolder;
|
||||
|
||||
|
@ -124,11 +124,13 @@ class NoteEditorState extends State<NoteEditor> with WidgetsBindingObserver {
|
||||
|
||||
if (existingImages.isNotEmpty) {
|
||||
for (var imagePath in existingImages) {
|
||||
() async {
|
||||
try {
|
||||
note!.addImageSync(imagePath);
|
||||
await note!.addImage(imagePath);
|
||||
} catch (e, st) {
|
||||
Log.e("New Note Existing Image", ex: e, stacktrace: st);
|
||||
}
|
||||
}();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user