mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-03 12:41:45 +02:00
fix: some notes from backup not being restored
This commit is contained in:
1
packages/core/__tests__/__fixtures__/backup.v4.3.json
Normal file
1
packages/core/__tests__/__fixtures__/backup.v4.3.json
Normal file
File diff suppressed because one or more lines are too long
@@ -9,6 +9,7 @@ import v2Backup from "./__fixtures__/backup.v2.json";
|
||||
import v3Backup from "./__fixtures__/backup.v3.json";
|
||||
import v4Backup from "./__fixtures__/backup.v4.json";
|
||||
import v42Backup from "./__fixtures__/backup.v4.2.json";
|
||||
import v43Backup from "./__fixtures__/backup.v4.3.json";
|
||||
|
||||
beforeEach(() => {
|
||||
StorageInterface.clear();
|
||||
@@ -74,6 +75,7 @@ describe.each([
|
||||
["v3", v3Backup],
|
||||
["v4", v4Backup],
|
||||
["v4.2", v42Backup],
|
||||
["v4.3", v43Backup],
|
||||
])("testing backup version: %s", (version, data) => {
|
||||
test(`import ${version} backup`, () => {
|
||||
return databaseTest().then(async (db) => {
|
||||
|
||||
@@ -97,7 +97,7 @@ test("delete note from edited topic", () =>
|
||||
})
|
||||
));
|
||||
|
||||
test.only("editing one topic should not update dateEdited of all", () =>
|
||||
test("editing one topic should not update dateEdited of all", () =>
|
||||
notebookTest().then(async ({ db, id }) => {
|
||||
let topics = db.notebooks.notebook(id).topics;
|
||||
|
||||
|
||||
@@ -44,8 +44,6 @@ const MAX_ITEMS = 5;
|
||||
const tests = [
|
||||
getMainCollectionParams("notes", TEST_NOTE),
|
||||
getMainCollectionParams("notebooks", TEST_NOTEBOOK),
|
||||
getTagsCollectionParams("tags", "someTag"),
|
||||
getTagsCollectionParams("colors", "red"),
|
||||
getMainCollectionParams("trash", {
|
||||
id: 2141,
|
||||
type: "note",
|
||||
|
||||
@@ -39,8 +39,6 @@ test("null server response should return false", async () => {
|
||||
const tests = [
|
||||
mainCollectionParams("notes", "note", TEST_NOTE),
|
||||
mainCollectionParams("notebooks", "notebook", TEST_NOTEBOOK),
|
||||
tagsCollectionParams("tags", "someTag", "tag"),
|
||||
tagsCollectionParams("colors", "red", "tag"),
|
||||
];
|
||||
|
||||
describe.each(tests)(
|
||||
|
||||
@@ -39,7 +39,7 @@ export default class Notes extends Collection {
|
||||
await this._db.colors.add(noteArg.color, id);
|
||||
}
|
||||
|
||||
if (noteArg.tags.length) {
|
||||
if (noteArg.tags && noteArg.tags.length) {
|
||||
for (let tag of noteArg.tags) {
|
||||
await this._db.tags.add(tag, id);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ export default class Notes extends Collection {
|
||||
...noteArg,
|
||||
};
|
||||
|
||||
if (!oldNote && !noteArg.content) return;
|
||||
if (!oldNote && !noteArg.content && !noteArg.contentId) return;
|
||||
|
||||
if (noteArg.content && noteArg.content.data && noteArg.content.type) {
|
||||
const { type, data, conflicted, resolved } = noteArg.content;
|
||||
|
||||
@@ -11,11 +11,13 @@ class Migrator {
|
||||
collection.index.map(async (id) => {
|
||||
let item = get(id);
|
||||
if (!item) return;
|
||||
|
||||
if (item.deleted)
|
||||
return await collection.dbCollection._collection.addItem(item);
|
||||
|
||||
const migrate = migrations[version][item.type || id];
|
||||
if (migrate) item = migrate(item);
|
||||
|
||||
if (!!collection.dbCollection.merge) {
|
||||
await collection.dbCollection.merge(item);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user