Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix topic not added

ammarahm-ed2dd7d937be97
diff --git a/apps/mobile/src/components/AddNotebookDialog/index.js b/apps/mobile/src/components/AddNotebookDialog/index.js
index 8f0eb627a..ac57f1026 100644
--- a/apps/mobile/src/components/AddNotebookDialog/index.js
+++ b/apps/mobile/src/components/AddNotebookDialog/index.js
@@ -108,33 +108,42 @@ export class AddNotebookDialog extends React.Component {
if (this.currentInputValue) {
this.onSubmit();
}
- let {topics} = this.state;
- let {toEdit} = this.props;
- if (!this.title)
- return ToastEvent.show('Title is required', 'error', 3000, () => {}, '');
- let id = toEdit && toEdit.id ? toEdit.id : null;
+ setTimeout(async () => {
+ let {topics} = this.state;
+ let {toEdit} = this.props;
+ if (!this.title)
+ return ToastEvent.show(
+ 'Title is required',
+ 'error',
+ 3000,
+ () => {},
+ '',
+ );
- if (id) {
- await db.notebooks.add({
- title: this.title,
- description: this.description,
- id: id,
- });
+ let id = toEdit && toEdit.id ? toEdit.id : null;
- await db.notebooks.notebook(id).topics.add(...topics);
- } else {
- await db.notebooks.add({
- title: this.title,
- description: this.description,
- topics,
- id: id,
- });
- }
+ if (id) {
+ await db.notebooks.add({
+ title: this.title,
+ description: this.description,
+ id: id,
+ });
+
+ await db.notebooks.notebook(id).topics.add(...topics);
+ } else {
+ await db.notebooks.add({
+ title: this.title,
+ description: this.description,
+ topics,
+ id: id,
+ });
+ }
+ this.close();
+ updateEvent({type: ACTIONS.NOTEBOOKS});
- updateEvent({type: ACTIONS.NOTEBOOKS});
- this.close();
- ToastEvent.show('New notebook added', 'success', 3000, () => {}, '');
+ ToastEvent.show('New notebook added', 'success', 3000, () => {}, '');
+ }, 100);
};
onSubmit = () => {