mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 09:47:35 +08:00
Copy Note to clipboard when it cannot be saved
Also avoid showing the actual exception. It's not very useful to the user, and we're logging the exception to Sentry anyway. Related to #124
This commit is contained in:
@ -62,7 +62,9 @@ editors:
|
||||
addImage: Add Image from Gallery
|
||||
editFileName: Edit File Name
|
||||
tags: Edit Tags
|
||||
saveNoteFailed: Failed to Save Note
|
||||
saveNoteFailed:
|
||||
title: Failed to Save Note
|
||||
message: We're sorry, but we cannot seem to save the Note. It has been copied to the clipboard to avoid data loss.
|
||||
pro: Pro
|
||||
actions:
|
||||
newNote: New Note
|
||||
|
@ -303,6 +303,10 @@ class Note with NotesNotifier {
|
||||
await file.writeAsString(contents);
|
||||
}
|
||||
|
||||
String serialize() {
|
||||
return _serializer.encode(data);
|
||||
}
|
||||
|
||||
// FIXME: What about error handling?
|
||||
Future<void> remove() async {
|
||||
assert(_filePath != null);
|
||||
|
@ -3,6 +3,7 @@ import 'dart:io';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'package:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/core/md_yaml_doc.dart';
|
||||
@ -331,11 +332,12 @@ class NoteEditorState extends State<NoteEditor> {
|
||||
: await stateContainer.updateNote(note);
|
||||
} catch (e, stackTrace) {
|
||||
logException(e, stackTrace);
|
||||
Clipboard.setData(ClipboardData(text: note.serialize()));
|
||||
|
||||
await showAlertDialog(
|
||||
context,
|
||||
tr("editors.common.saveNoteFailed"),
|
||||
e.toString(),
|
||||
tr("editors.common.saveNoteFailed.title"),
|
||||
tr("editors.common.saveNoteFailed.message"),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user