mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Handle case when note is deleted while being edited. Show note on map.
This commit is contained in:
parent
4f7edf8371
commit
729b8f7c79
@ -81,6 +81,8 @@ class Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadItems(type, pattern, options = null) {
|
async loadItems(type, pattern, options = null) {
|
||||||
|
pattern = pattern ? pattern.toString() : '';
|
||||||
|
|
||||||
if (type == BaseModel.TYPE_FOLDER && (pattern == Folder.conflictFolderTitle() || pattern == Folder.conflictFolderId())) return [Folder.conflictFolder()];
|
if (type == BaseModel.TYPE_FOLDER && (pattern == Folder.conflictFolderTitle() || pattern == Folder.conflictFolderId())) return [Folder.conflictFolder()];
|
||||||
|
|
||||||
if (!options) options = {};
|
if (!options) options = {};
|
||||||
|
@ -15,52 +15,52 @@ msgstr ""
|
|||||||
"Content-Type: text/plain; charset=CHARSET\n"
|
"Content-Type: text/plain; charset=CHARSET\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:92
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:94
|
||||||
msgid "No notebook selected."
|
msgid "No notebook selected."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:97
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:99
|
||||||
msgid "No notebook has been specified."
|
msgid "No notebook has been specified."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:128
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:130
|
||||||
msgid "Usage: --profile <dir-path>"
|
msgid "Usage: --profile <dir-path>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:135
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:137
|
||||||
msgid "Usage: --env <dev|prod>"
|
msgid "Usage: --env <dev|prod>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:160
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:162
|
||||||
msgid "Usage: --log-level <none|error|warn|info|debug>"
|
msgid "Usage: --log-level <none|error|warn|info|debug>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:167
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:169
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid "Unknown flag: %s"
|
msgid "Unknown flag: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:183
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:185
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"Command line argument \"%s\" contains both quotes and double-quotes - "
|
"Command line argument \"%s\" contains both quotes and double-quotes - "
|
||||||
"aborting."
|
"aborting."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:203
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
||||||
msgid "Provides help for a given command."
|
msgid "Provides help for a given command."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:207
|
||||||
msgid "Exits the application."
|
msgid "Exits the application."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:337
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:339
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid "Synchronizing with directory \"%s\""
|
msgid "Synchronizing with directory \"%s\""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:420
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:422
|
||||||
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
|
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -553,7 +553,7 @@ msgstr ""
|
|||||||
msgid "Show metadata"
|
msgid "Show metadata"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:395
|
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:409
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -15,32 +15,32 @@ msgstr ""
|
|||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"X-Generator: Poedit 1.8.7.1\n"
|
"X-Generator: Poedit 1.8.7.1\n"
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:92
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:94
|
||||||
msgid "No notebook selected."
|
msgid "No notebook selected."
|
||||||
msgstr "Aucun carnet n'est sélectionné."
|
msgstr "Aucun carnet n'est sélectionné."
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:97
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:99
|
||||||
msgid "No notebook has been specified."
|
msgid "No notebook has been specified."
|
||||||
msgstr "Aucun carnet n'est spécifié."
|
msgstr "Aucun carnet n'est spécifié."
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:128
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:130
|
||||||
msgid "Usage: --profile <dir-path>"
|
msgid "Usage: --profile <dir-path>"
|
||||||
msgstr "Utilisation: --profile <chemin>"
|
msgstr "Utilisation: --profile <chemin>"
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:135
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:137
|
||||||
msgid "Usage: --env <dev|prod>"
|
msgid "Usage: --env <dev|prod>"
|
||||||
msgstr "Utilisation : --env <dev|prod>"
|
msgstr "Utilisation : --env <dev|prod>"
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:160
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:162
|
||||||
msgid "Usage: --log-level <none|error|warn|info|debug>"
|
msgid "Usage: --log-level <none|error|warn|info|debug>"
|
||||||
msgstr "Utilisation: --log-level <none|error|warn|info|debug>"
|
msgstr "Utilisation: --log-level <none|error|warn|info|debug>"
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:167
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:169
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid "Unknown flag: %s"
|
msgid "Unknown flag: %s"
|
||||||
msgstr "Paramètre inconnu : %s"
|
msgstr "Paramètre inconnu : %s"
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:183
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:185
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"Command line argument \"%s\" contains both quotes and double-quotes - "
|
"Command line argument \"%s\" contains both quotes and double-quotes - "
|
||||||
@ -49,20 +49,20 @@ msgstr ""
|
|||||||
"Paramètre de ligne de command \"%s\" contient à la fois des guillemets "
|
"Paramètre de ligne de command \"%s\" contient à la fois des guillemets "
|
||||||
"simples et doubles - impossible de continuer."
|
"simples et doubles - impossible de continuer."
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:203
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
||||||
msgid "Provides help for a given command."
|
msgid "Provides help for a given command."
|
||||||
msgstr "Affiche l'aide pour la commande donnée."
|
msgstr "Affiche l'aide pour la commande donnée."
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:207
|
||||||
msgid "Exits the application."
|
msgid "Exits the application."
|
||||||
msgstr "Quitter le logiciel."
|
msgstr "Quitter le logiciel."
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:337
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:339
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid "Synchronizing with directory \"%s\""
|
msgid "Synchronizing with directory \"%s\""
|
||||||
msgstr "Synchronisation avec dossier \"%s\""
|
msgstr "Synchronisation avec dossier \"%s\""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:420
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:422
|
||||||
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
|
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
|
||||||
msgstr "Aucun carnet n'est défini. Créez-en un avec `mkbook <carnet>`."
|
msgstr "Aucun carnet n'est défini. Créez-en un avec `mkbook <carnet>`."
|
||||||
|
|
||||||
@ -593,7 +593,7 @@ msgstr ""
|
|||||||
msgid "Show metadata"
|
msgid "Show metadata"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:395
|
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:409
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -15,52 +15,52 @@ msgstr ""
|
|||||||
"Content-Type: text/plain; charset=CHARSET\n"
|
"Content-Type: text/plain; charset=CHARSET\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:92
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:94
|
||||||
msgid "No notebook selected."
|
msgid "No notebook selected."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:97
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:99
|
||||||
msgid "No notebook has been specified."
|
msgid "No notebook has been specified."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:128
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:130
|
||||||
msgid "Usage: --profile <dir-path>"
|
msgid "Usage: --profile <dir-path>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:135
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:137
|
||||||
msgid "Usage: --env <dev|prod>"
|
msgid "Usage: --env <dev|prod>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:160
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:162
|
||||||
msgid "Usage: --log-level <none|error|warn|info|debug>"
|
msgid "Usage: --log-level <none|error|warn|info|debug>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:167
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:169
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid "Unknown flag: %s"
|
msgid "Unknown flag: %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:183
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:185
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"Command line argument \"%s\" contains both quotes and double-quotes - "
|
"Command line argument \"%s\" contains both quotes and double-quotes - "
|
||||||
"aborting."
|
"aborting."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:203
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
||||||
msgid "Provides help for a given command."
|
msgid "Provides help for a given command."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:205
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:207
|
||||||
msgid "Exits the application."
|
msgid "Exits the application."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:337
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:339
|
||||||
#, javascript-format
|
#, javascript-format
|
||||||
msgid "Synchronizing with directory \"%s\""
|
msgid "Synchronizing with directory \"%s\""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:420
|
#: /mnt/d/Web/www/joplin/CliClient/app/app.js:422
|
||||||
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
|
msgid "No notebook is defined. Create one with `mkbook <notebook>`."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -553,7 +553,7 @@ msgstr ""
|
|||||||
msgid "Show metadata"
|
msgid "Show metadata"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:395
|
#: /mnt/d/Web/www/joplin/ReactNativeClient/lib/components/screens/note.js:409
|
||||||
msgid "Edit"
|
msgid "Edit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -167,9 +167,18 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
this.noteComponent_change('body', text);
|
this.noteComponent_change('body', text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async noteExists(noteId) {
|
||||||
|
const existingNote = await Note.load(noteId);
|
||||||
|
return !!existingNote;
|
||||||
|
}
|
||||||
|
|
||||||
async saveNoteButton_press() {
|
async saveNoteButton_press() {
|
||||||
let note = Object.assign({}, this.state.note);
|
let note = Object.assign({}, this.state.note);
|
||||||
|
|
||||||
|
// Note has been deleted while user was modifying it. In that, we
|
||||||
|
// just save a new note by clearing the note ID.
|
||||||
|
if (note.id && !(await this.noteExists(note.id))) delete note.id;
|
||||||
|
|
||||||
reg.logger().info('Saving note: ', note);
|
reg.logger().info('Saving note: ', note);
|
||||||
|
|
||||||
if (!note.parent_id) {
|
if (!note.parent_id) {
|
||||||
@ -194,6 +203,33 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
reg.scheduleSync();
|
reg.scheduleSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async saveOneProperty(name, value) {
|
||||||
|
let note = Object.assign({}, this.state.note);
|
||||||
|
|
||||||
|
// Note has been deleted while user was modifying it. In that, we
|
||||||
|
// just save a new note by clearing the note ID.
|
||||||
|
if (note.id && !(await this.noteExists(note.id))) delete note.id;
|
||||||
|
|
||||||
|
reg.logger().info('Saving note property: ', note.id, name, value);
|
||||||
|
|
||||||
|
if (note.id) {
|
||||||
|
let toSave = { id: note.id };
|
||||||
|
toSave[name] = value;
|
||||||
|
toSave = await Note.save(toSave);
|
||||||
|
note[name] = toSave[name];
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
lastSavedNote: Object.assign({}, note),
|
||||||
|
note: note,
|
||||||
|
});
|
||||||
|
|
||||||
|
reg.scheduleSync();
|
||||||
|
} else {
|
||||||
|
note[name] = value;
|
||||||
|
this.setState({ note: note });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async deleteNote_onPress() {
|
async deleteNote_onPress() {
|
||||||
let note = this.state.note;
|
let note = this.state.note;
|
||||||
if (!note.id) return;
|
if (!note.id) return;
|
||||||
@ -225,6 +261,18 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
this.refreshNoteMetadata(true);
|
this.refreshNoteMetadata(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async showOnMap_onPress() {
|
||||||
|
if (!this.state.note.id) return;
|
||||||
|
|
||||||
|
let note = await Note.load(this.state.note.id);
|
||||||
|
try {
|
||||||
|
const url = Note.geolocationUrl(note);
|
||||||
|
Linking.openURL(url);
|
||||||
|
} catch (error) {
|
||||||
|
await dialogs.error(this, error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
menuOptions() {
|
menuOptions() {
|
||||||
const note = this.state.note;
|
const note = this.state.note;
|
||||||
|
|
||||||
@ -233,32 +281,10 @@ class NoteScreenComponent extends BaseScreenComponent {
|
|||||||
{ title: _('Delete note'), onPress: () => { this.deleteNote_onPress(); } },
|
{ title: _('Delete note'), onPress: () => { this.deleteNote_onPress(); } },
|
||||||
{ title: note && !!note.is_todo ? _('Convert to regular note') : _('Convert to todo'), onPress: () => { this.toggleIsTodo_onPress(); } },
|
{ title: note && !!note.is_todo ? _('Convert to regular note') : _('Convert to todo'), onPress: () => { this.toggleIsTodo_onPress(); } },
|
||||||
{ title: this.state.showNoteMetadata ? _('Hide metadata') : _('Show metadata'), onPress: () => { this.showMetadata_onPress(); } },
|
{ title: this.state.showNoteMetadata ? _('Hide metadata') : _('Show metadata'), onPress: () => { this.showMetadata_onPress(); } },
|
||||||
|
{ title: _('View location on map'), onPress: () => { this.showOnMap_onPress(); } },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveOneProperty(name, value) {
|
|
||||||
let note = Object.assign({}, this.state.note);
|
|
||||||
|
|
||||||
reg.logger().info('Saving note property: ', note.id, name, value);
|
|
||||||
|
|
||||||
if (note.id) {
|
|
||||||
let toSave = { id: note.id };
|
|
||||||
toSave[name] = value;
|
|
||||||
toSave = await Note.save(toSave);
|
|
||||||
note[name] = toSave[name];
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
lastSavedNote: Object.assign({}, note),
|
|
||||||
note: note,
|
|
||||||
});
|
|
||||||
|
|
||||||
reg.scheduleSync();
|
|
||||||
} else {
|
|
||||||
note[name] = value;
|
|
||||||
this.setState({ note: note });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async todoCheckbox_change(checked) {
|
async todoCheckbox_change(checked) {
|
||||||
await this.saveOneProperty('todo_completed', checked ? time.unixMs() : 0);
|
await this.saveOneProperty('todo_completed', checked ? time.unixMs() : 0);
|
||||||
reg.scheduleSync();
|
reg.scheduleSync();
|
||||||
|
@ -42,7 +42,7 @@ class Note extends BaseItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static geolocationUrl(note) {
|
static geolocationUrl(note) {
|
||||||
if (!('latitude' in note) || !('longitude' in note)) throw new Error('Latitude or longitude missing');
|
if (!('latitude' in note) || !('longitude' in note)) throw new Error('Latitude or longitude is missing');
|
||||||
if (!note.latitude && !note.longitude) throw new Error(_('This note does not have geolocation information.'));
|
if (!note.latitude && !note.longitude) throw new Error(_('This note does not have geolocation information.'));
|
||||||
return sprintf('https://www.openstreetmap.org/?lat=%s&lon=%s&zoom=20', note.latitude, note.longitude)
|
return sprintf('https://www.openstreetmap.org/?lat=%s&lon=%s&zoom=20', note.latitude, note.longitude)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user