1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-26 18:58:21 +02:00

Desktop: Fixes #1720: Fixed issue with certain commands being repeated in some cases

This commit is contained in:
Laurent Cozic 2019-07-13 16:57:33 +01:00
parent 331858bd4f
commit f7203ed7e2

View File

@ -94,17 +94,15 @@ class MainScreenComponent extends React.Component {
if (command.name === 'newNote') {
if (!this.props.folders.length) {
bridge().showErrorMessageBox(_('Please create a notebook first.'));
return;
} else {
await createNewNote(null, false);
}
await createNewNote(null, false);
} else if (command.name === 'newTodo') {
if (!this.props.folders.length) {
bridge().showErrorMessageBox(_('Please create a notebook first'));
return;
} else {
await createNewNote(null, true);
}
await createNewNote(null, true);
} else if (command.name === 'newNotebook') {
this.setState({
promptOptions: {
@ -153,47 +151,47 @@ class MainScreenComponent extends React.Component {
});
} else if (command.name === 'renameFolder') {
const folder = await Folder.load(command.id);
if (!folder) return;
this.setState({
promptOptions: {
label: _('Rename notebook:'),
value: folder.title,
onClose: async (answer) => {
if (answer !== null) {
try {
folder.title = answer;
await Folder.save(folder, { fields: ['title'], userSideValidation: true });
} catch (error) {
bridge().showErrorMessageBox(error.message);
if (folder) {
this.setState({
promptOptions: {
label: _('Rename notebook:'),
value: folder.title,
onClose: async (answer) => {
if (answer !== null) {
try {
folder.title = answer;
await Folder.save(folder, { fields: ['title'], userSideValidation: true });
} catch (error) {
bridge().showErrorMessageBox(error.message);
}
}
this.setState({ promptOptions: null });
}
this.setState({ promptOptions: null });
}
},
});
},
});
}
} else if (command.name === 'renameTag') {
const tag = await Tag.load(command.id);
if(!tag) return;
this.setState({
promptOptions: {
label: _('Rename tag:'),
value: tag.title,
onClose: async (answer) => {
if (answer !== null) {
try {
tag.title = answer;
await Tag.save(tag, { fields: ['title'], userSideValidation: true });
} catch (error) {
bridge().showErrorMessageBox(error.message);
if (tag) {
this.setState({
promptOptions: {
label: _('Rename tag:'),
value: tag.title,
onClose: async (answer) => {
if (answer !== null) {
try {
tag.title = answer;
await Tag.save(tag, { fields: ['title'], userSideValidation: true });
} catch (error) {
bridge().showErrorMessageBox(error.message);
}
}
this.setState({promptOptions: null });
}
this.setState({promptOptions: null });
}
}
})
})
}
} else if (command.name === 'search') {
if (!this.searchId_) this.searchId_ = uuid.create();