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