mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 06:29:29 +01:00
fix adding notebook
This commit is contained in:
@@ -114,7 +114,6 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
addNewNotebook = async () => {
|
addNewNotebook = async () => {
|
||||||
|
|
||||||
let {topics} = this.state;
|
let {topics} = this.state;
|
||||||
let edit = this.props.toEdit;
|
let edit = this.props.toEdit;
|
||||||
|
|
||||||
@@ -130,10 +129,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
|
|
||||||
let prevTopics = [...topics];
|
let prevTopics = [...topics];
|
||||||
|
|
||||||
if (
|
if (this.currentInputValue && this.currentInputValue.trim().length !== 0) {
|
||||||
this.currentInputValue &&
|
|
||||||
this.currentInputValue.trim().length !== 0
|
|
||||||
) {
|
|
||||||
if (this.prevItem != null) {
|
if (this.prevItem != null) {
|
||||||
prevTopics[this.prevIndex] = this.currentInputValue;
|
prevTopics[this.prevIndex] = this.currentInputValue;
|
||||||
} else {
|
} else {
|
||||||
@@ -142,7 +138,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (id) {
|
if (id) {
|
||||||
if (this.topicsToDelete.length > 0) {
|
if (this.topicsToDelete?.length > 0) {
|
||||||
await db.notebooks
|
await db.notebooks
|
||||||
.notebook(toEdit.id)
|
.notebook(toEdit.id)
|
||||||
.topics.delete(...this.topicsToDelete);
|
.topics.delete(...this.topicsToDelete);
|
||||||
@@ -155,12 +151,11 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
id: id,
|
id: id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
let nextTopics = toEdit.topics.map((topic, index) => {
|
let nextTopics = toEdit.topics.map((topic, index) => {
|
||||||
if (index === 0) return topic;
|
if (index === 0) return topic;
|
||||||
let copy = {...topic};
|
let copy = {...topic};
|
||||||
console.log(copy,'here');
|
console.log(copy, 'here');
|
||||||
copy.title = prevTopics[index -1];
|
copy.title = prevTopics[index - 1];
|
||||||
return copy;
|
return copy;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -169,7 +164,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
nextTopics.push(title);
|
nextTopics.push(title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(nextTopics,prevTopics,toEdit.topics,"HERE");
|
console.log(nextTopics, prevTopics, toEdit.topics, 'HERE');
|
||||||
await db.notebooks.notebook(id).topics.add(...nextTopics);
|
await db.notebooks.notebook(id).topics.add(...nextTopics);
|
||||||
} else {
|
} else {
|
||||||
await db.notebooks.add({
|
await db.notebooks.add({
|
||||||
@@ -179,17 +174,16 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
id: id,
|
id: id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//this.close();
|
this.close();
|
||||||
updateEvent({type: ACTIONS.NOTEBOOKS});
|
updateEvent({type: ACTIONS.NOTEBOOKS});
|
||||||
updateEvent({type: ACTIONS.PINNED});
|
updateEvent({type: ACTIONS.PINNED});
|
||||||
|
|
||||||
ToastEvent.show('New notebook added', 'success', 'local');
|
//ToastEvent.show('New notebook added', 'success', 'local');
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onSubmit = (forward = true) => {
|
onSubmit = (forward = true) => {
|
||||||
let {topics} = this.state;
|
let {topics} = this.state;
|
||||||
if (!this.currentInputValue || this.currentInputValue.trim().length === 0)
|
if (!this.currentInputValue || this.currentInputValue?.trim().length === 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let prevTopics = [...topics];
|
let prevTopics = [...topics];
|
||||||
@@ -320,7 +314,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
styles.input,
|
styles.input,
|
||||||
{
|
{
|
||||||
borderColor: descFocused ? colors.accent : colors.nav,
|
borderColor: descFocused ? colors.accent : colors.nav,
|
||||||
minHeight:90,
|
minHeight: 90,
|
||||||
color: colors.pri,
|
color: colors.pri,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
@@ -385,7 +379,7 @@ export class AddNotebookDialog extends React.Component {
|
|||||||
color: colors.pri,
|
color: colors.pri,
|
||||||
width: '85%',
|
width: '85%',
|
||||||
maxWidth: '85%',
|
maxWidth: '85%',
|
||||||
marginTop:5
|
marginTop: 5,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
placeholder="Add a new topic"
|
placeholder="Add a new topic"
|
||||||
|
|||||||
Reference in New Issue
Block a user