mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
minor improvement in performance
This commit is contained in:
@@ -54,11 +54,11 @@ export class AddNotebookDialog extends React.Component {
|
||||
|
||||
if (toEdit && toEdit.type === 'notebook') {
|
||||
let topicsList = [];
|
||||
toEdit.topics.forEach((item) => {
|
||||
if (item.id !== 'General') {
|
||||
toEdit.topics.forEach((item, index) => {
|
||||
if (index === 0)return;
|
||||
topicsList.push(item.title);
|
||||
}
|
||||
});
|
||||
console.log(topicsList);
|
||||
this.id = toEdit.id;
|
||||
this.title = toEdit.title;
|
||||
this.description = toEdit.description;
|
||||
@@ -95,19 +95,16 @@ export class AddNotebookDialog extends React.Component {
|
||||
let {topics} = this.state;
|
||||
let prevTopics = topics;
|
||||
refs = [];
|
||||
console.log(prevTopics);
|
||||
prevTopics.splice(index, 1);
|
||||
let edit = this.props.toEdit;
|
||||
console.log(edit);
|
||||
if (edit && edit.id) {
|
||||
let topicToDelete = edit.topics[index];
|
||||
let topicToDelete = edit.topics[index + 1];
|
||||
console.log(topicToDelete)
|
||||
if (topicToDelete) {
|
||||
this.topicsToDelete.push(topicToDelete.id);
|
||||
}
|
||||
}
|
||||
let nextTopics = [...prevTopics];
|
||||
console.log(nextTopics);
|
||||
if (this.prevIndex === index) {
|
||||
this.prevIndex = null;
|
||||
this.prevItem = null;
|
||||
@@ -147,7 +144,6 @@ export class AddNotebookDialog extends React.Component {
|
||||
}
|
||||
}
|
||||
if (id) {
|
||||
console.log('topics to delete',this.topicsToDelete?.length)
|
||||
|
||||
if (this.topicsToDelete?.length > 0) {
|
||||
await db.notebooks
|
||||
@@ -155,7 +151,6 @@ export class AddNotebookDialog extends React.Component {
|
||||
.topics.delete(...this.topicsToDelete);
|
||||
toEdit = db.notebooks.notebook(toEdit.id).data;
|
||||
}
|
||||
console.log(toEdit.topics);
|
||||
|
||||
await db.notebooks.add({
|
||||
title: this.title,
|
||||
@@ -175,7 +170,7 @@ export class AddNotebookDialog extends React.Component {
|
||||
nextTopics.push(title);
|
||||
}
|
||||
});
|
||||
console.log('nextTopics',nextTopics);
|
||||
|
||||
await db.notebooks.notebook(id).topics.add(...nextTopics);
|
||||
} else {
|
||||
await db.notebooks.add({
|
||||
|
||||
Reference in New Issue
Block a user