1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Improved back button handling when note has been modified

This commit is contained in:
Laurent Cozic
2017-08-24 18:10:03 +00:00
parent d9c85a7275
commit 7aaf4fb491
6 changed files with 106 additions and 26 deletions

View File

@ -32,6 +32,30 @@ dialogs.confirm = (parentComponent, message) => {
});
};
dialogs.pop = (parentComponent, message, buttons) => {
if (!'dialogbox' in parentComponent) throw new Error('A "dialogbox" component must be defined on the parent component!');
return new Promise((resolve, reject) => {
Keyboard.dismiss();
let btns = [];
for (let i = 0; i < buttons.length; i++) {
btns.push({
text: buttons[i].title,
callback: () => {
parentComponent.dialogbox.close();
resolve(buttons[i].id);
},
});
}
parentComponent.dialogbox.pop({
content: message,
btns: btns,
});
});
}
dialogs.error = (parentComponent, message) => {
Keyboard.dismiss();
return parentComponent.dialogbox.alert(message);