1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-29 22:48:10 +02:00

Mobile: Fixes #244: When accessing configuration or encrypt configuration option while making a note and the going back, the note gets erased

This commit is contained in:
Laurent Cozic
2018-02-21 22:08:34 +00:00
parent 14a93a9f26
commit 71aa841265
4 changed files with 59 additions and 25 deletions

View File

@@ -9,6 +9,7 @@ const Setting = require('lib/models/Setting.js');
const Resource = require('lib/models/Resource.js');
const Folder = require('lib/models/Folder.js');
const { BackButtonService } = require('lib/services/back-button.js');
const NavService = require('lib/services/NavService.js');
const BaseModel = require('lib/BaseModel.js');
const { ActionButton } = require('lib/components/action-button.js');
const Icon = require('react-native-vector-icons/Ionicons').default;
@@ -61,7 +62,7 @@ class NoteScreenComponent extends BaseScreenComponent {
this.styles_ = {};
this.backHandler = async () => {
const saveDialog = async () => {
if (this.isModified()) {
let buttonId = await dialogs.pop(this, _('This note has been modified:'), [
{ title: _('Save changes'), id: 'save' },
@@ -73,6 +74,17 @@ class NoteScreenComponent extends BaseScreenComponent {
if (buttonId == 'save') await this.saveNoteButton_press();
}
return false;
}
this.navHandler = async () => {
return await saveDialog();
}
this.backHandler = async () => {
const r = await saveDialog();
if (r) return r;
if (!this.state.note.id) {
return false;
}
@@ -145,6 +157,7 @@ class NoteScreenComponent extends BaseScreenComponent {
async componentWillMount() {
BackButtonService.addHandler(this.backHandler);
NavService.addHandler(this.navHandler);
await shared.initState(this);
@@ -157,6 +170,7 @@ class NoteScreenComponent extends BaseScreenComponent {
componentWillUnmount() {
BackButtonService.removeHandler(this.backHandler);
NavService.removeHandler(this.navHandler);
}
title_changeText(text) {