Skip to content

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

feat: no need to add default General topic to notebooks

thecodrr161946928f6f
diff --git a/packages/core/__tests__/notebooks.test.js b/packages/core/__tests__/notebooks.test.js
index fb0903d0f..c5d2d8ea1 100644
--- a/packages/core/__tests__/notebooks.test.js
+++ b/packages/core/__tests__/notebooks.test.js
@@ -57,7 +57,6 @@ test("merge notebook with new topics", () =>
await expect(db.notebooks.merge(newNotebook)).resolves.not.toThrow();
expect(notebook.topics.has("Home")).toBe(true);
- expect(notebook.topics.has("General")).toBe(true);
expect(notebook.topics.has("hello")).toBe(true);
}));
@@ -66,13 +65,12 @@ test("merge notebook with topics removed", () =>
let notebook = db.notebooks.notebook(id);
const newNotebook = { ...notebook.data, remote: true };
- newNotebook.topics.splice(1, 1); // remove hello topic
+ newNotebook.topics.splice(0, 1); // remove hello topic
newNotebook.topics.push(makeTopic("Home", id));
await expect(db.notebooks.merge(newNotebook)).resolves.not.toThrow();
expect(notebook.topics.has("Home")).toBe(true);
- expect(notebook.topics.has("General")).toBe(true);
expect(notebook.topics.has("hello")).toBe(false);
}));
@@ -81,7 +79,7 @@ test("merge notebook with topic edited", () =>
let notebook = db.notebooks.notebook(id);
const newNotebook = { ...notebook.data, remote: true };
- newNotebook.topics[1].title = "hello (edited)";
+ newNotebook.topics[0].title = "hello (edited)";
await expect(db.notebooks.merge(newNotebook)).resolves.not.toThrow();
@@ -94,12 +92,12 @@ test("merge notebook when local notebook is also edited", () =>
let notebook = db.notebooks.notebook(id);
const newNotebook = { ...notebook.data, remote: true };
- newNotebook.topics[1].title = "hello (edited)";
+ newNotebook.topics[0].title = "hello (edited)";
await delay(500);
await notebook.topics.add({
- ...notebook.topics.all[1],
+ ...notebook.topics.all[0],
title: "hello (edited too)",
});
@@ -115,7 +113,7 @@ test("merge notebook with topic removed that is edited in the local notebook", (
let notebook = db.notebooks.notebook(id);
const newNotebook = { ...notebook.data, remote: true };
- newNotebook.topics.splice(1, 1); // remove hello topic
+ newNotebook.topics.splice(0, 1); // remove hello topic
await StorageInterface.write("lastSynced", Date.now());
diff --git a/packages/core/__tests__/notes.test.js b/packages/core/__tests__/notes.test.js
index c84a1992c..23d08aa48 100644
--- a/packages/core/__tests__/notes.test.js
+++ b/packages/core/__tests__/notes.test.js
@@ -39,9 +39,9 @@ test("delete note", () =>
noteTest().then(async ({ db, id }) => {
let notebookId = await db.notebooks.add(TEST_NOTEBOOK);
let topics = db.notebooks.notebook(notebookId).topics;
- let topic = topics.topic("General");
+ let topic = topics.topic("hello");
await topic.add(id);
- topic = topics.topic("General");
+ topic = topics.topic("hello");
expect(topic.all.findIndex((v) => v.id === id)).toBeGreaterThan(-1);
await db.notes.delete(id);
@@ -49,7 +49,7 @@ test("delete note", () =>
expect(topic.all.findIndex((v) => v.id === id)).toBe(-1);
expect(db.notebooks.notebook(notebookId).totalNotes).toBe(0);
- expect(topics.topic("General").totalNotes).toBe(0);
+ expect(topics.topic("hello").totalNotes).toBe(0);
}));
test("get all notes", () =>
diff --git a/packages/core/__tests__/topics.test.js b/packages/core/__tests__/topics.test.js
index de4842116..5eccf1149 100644
--- a/packages/core/__tests__/topics.test.js
+++ b/packages/core/__tests__/topics.test.js
@@ -4,7 +4,7 @@ beforeEach(() => StorageInterface.clear());
test("get empty topic", () =>
notebookTest().then(({ db, id }) => {
- let topic = db.notebooks.notebook(id).topics.topic("General");
+ let topic = db.notebooks.notebook(id).topics.topic("hello");
expect(topic.all.length).toBe(0);
}));
@@ -59,7 +59,7 @@ test("edit topic title", () =>
let topic = topics.topic("Home");
- expect(topics.all.length).toBe(3);
+ expect(topics.all.length).toBe(2);
const oldDateEdited = topic._topic.dateEdited;
@@ -67,7 +67,7 @@ test("edit topic title", () =>
await topics.add({ id: topic._topic.id, title: "Hello22" });
- expect(topics.all.length).toBe(3);
+ expect(topics.all.length).toBe(2);
expect(topics.topic(topic._topic.id)._topic.title).toBe("Hello22");
expect(topics.topic(topic._topic.id)._topic.dateEdited).toBeGreaterThan(
oldDateEdited
diff --git a/packages/core/__tests__/trash.test.js b/packages/core/__tests__/trash.test.js
index a28265148..3af6a9e28 100644
--- a/packages/core/__tests__/trash.test.js
+++ b/packages/core/__tests__/trash.test.js
@@ -29,7 +29,7 @@ test("permanently delete a note", () =>
test("restore a deleted note that was in a notebook", () =>
noteTest().then(async ({ db, id }) => {
let nbId = await db.notebooks.add(TEST_NOTEBOOK);
- await db.notebooks.notebook(nbId).topics.topic("General").add(id);
+ await db.notebooks.notebook(nbId).topics.topic("hello").add(id);
await db.notes.delete(id);
await db.trash.restore(db.trash.all[0].id);
expect(db.trash.all.length).toBe(0);
@@ -40,11 +40,11 @@ test("restore a deleted note that was in a notebook", () =>
expect(await note.content()).toBe(TEST_NOTE.content.data);
const notebook = db.notebooks.notebook(nbId);
- expect(notebook.topics.topic("General").has(id)).toBe(true);
+ expect(notebook.topics.topic("hello").has(id)).toBe(true);
expect(note.notebooks.some((n) => n.id === nbId)).toBe(true);
- expect(notebook.topics.has("General")).toBeDefined();
+ expect(notebook.topics.has("hello")).toBeDefined();
}));
test("delete a locked note", () =>
@@ -74,7 +74,7 @@ test("restore a deleted locked note", () =>
test("restore a deleted note that's in a deleted notebook", () =>
noteTest().then(async ({ db, id }) => {
let nbId = await db.notebooks.add(TEST_NOTEBOOK);
- await db.notebooks.notebook(nbId).topics.topic("General").add(id);
+ await db.notebooks.notebook(nbId).topics.topic("hello").add(id);
await db.notes.delete(id);
await db.notebooks.delete(nbId);
const deletedNote = db.trash.all.find(
@@ -89,7 +89,7 @@ test("restore a deleted note that's in a deleted notebook", () =>
test("delete a notebook", () =>
notebookTest().then(async ({ db, id }) => {
let noteId = await db.notes.add(TEST_NOTE);
- await db.notebooks.notebook(id).topics.topic("General").add(noteId);
+ await db.notebooks.notebook(id).topics.topic("hello").add(noteId);
await db.notebooks.delete(id);
expect(db.notebooks.notebook(id)).toBeUndefined();
expect(db.notes.note(noteId).notebook).toBeUndefined();
@@ -98,7 +98,7 @@ test("delete a notebook", () =>
test("restore a deleted notebook", () =>
notebookTest().then(async ({ db, id }) => {
let noteId = await db.notes.add(TEST_NOTE);
- await db.notebooks.notebook(id).topics.topic("General").add(noteId);
+ await db.notebooks.notebook(id).topics.topic("hello").add(noteId);
await db.notebooks.delete(id);
await db.trash.restore(id);
let notebook = db.notebooks.notebook(id);
@@ -114,7 +114,7 @@ test("restore a deleted notebook", () =>
test("restore a notebook that has deleted notes", () =>
notebookTest().then(async ({ db, id }) => {
let noteId = await db.notes.add(TEST_NOTE);
- await db.notebooks.notebook(id).topics.topic("General").add(noteId);
+ await db.notebooks.notebook(id).topics.topic("hello").add(noteId);
await db.notebooks.delete(id);
await db.notes.delete(noteId);
const deletedNotebook = db.trash.all.find(
@@ -123,5 +123,5 @@ test("restore a notebook that has deleted notes", () =>
await db.trash.restore(deletedNotebook.id);
let notebook = db.notebooks.notebook(id);
expect(notebook).toBeDefined();
- expect(notebook.topics.topic("General").has(noteId)).toBe(false);
+ expect(notebook.topics.topic("hello").has(noteId)).toBe(false);
}));
diff --git a/packages/core/collections/notebooks.js b/packages/core/collections/notebooks.js
index 8f105a08a..3d231cc38 100644
--- a/packages/core/collections/notebooks.js
+++ b/packages/core/collections/notebooks.js
@@ -80,12 +80,6 @@ export default class Notebooks extends Collection {
pinned: !!notebook.pinned,
topics: notebook.topics || [],
};
- if (
- !oldNotebook &&
- notebook.topics.findIndex((topic) => topic.title === "General") <= -1
- ) {
- notebook.topics.splice(0, 0, "General");
- }
await this._collection.addItem(notebook);