You've already forked joplin
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user