mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
feat: add dateEdited to dateModified migration
This commit is contained in:
@@ -72,6 +72,8 @@ describe.each([["v5.2", v52Backup]])(
|
||||
await db.backup.import(JSON.stringify(data));
|
||||
|
||||
expect(db.settings.raw.id).toBeDefined();
|
||||
expect(db.settings.raw.dateModified).toBeDefined();
|
||||
expect(db.settings.raw.dateEdited).toBeUndefined();
|
||||
|
||||
expect(
|
||||
db.notes.all.every((v) => {
|
||||
@@ -80,21 +82,31 @@ describe.each([["v5.2", v52Backup]])(
|
||||
const hasTopicsInAllNotebooks =
|
||||
!v.notebooks ||
|
||||
v.notebooks.every((nb) => !!nb.id && !!nb.topics && !nb.topic);
|
||||
const hasDateModified = v.dateModified > 0;
|
||||
return (
|
||||
doesNotHaveContent &&
|
||||
!v.notebook &&
|
||||
hasTopicsInAllNotebooks &&
|
||||
doesNotHaveColors
|
||||
doesNotHaveColors &&
|
||||
hasDateModified
|
||||
);
|
||||
})
|
||||
).toBeTruthy();
|
||||
|
||||
expect(db.notebooks.all.every((v) => v.title != null)).toBeTruthy();
|
||||
expect(
|
||||
db.notebooks.all.every((v) => v.title != null && v.dateModified > 0)
|
||||
).toBeTruthy();
|
||||
|
||||
expect(
|
||||
db.attachments.all.every((v) => v.dateModified > 0 && !v.dateEdited)
|
||||
).toBeTruthy();
|
||||
|
||||
const allContent = await db.content.all();
|
||||
expect(
|
||||
allContent.every((v) => v.type === "tiny" || v.deleted)
|
||||
).toBeTruthy();
|
||||
expect(allContent.every((v) => !v.persistDateEdited)).toBeTruthy();
|
||||
expect(allContent.every((v) => v.dateModified > 0)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -105,6 +117,7 @@ describe.each([["v5.2", v52Backup]])(
|
||||
verifyIndex(data, db, "notes", "notes");
|
||||
verifyIndex(data, db, "notebooks", "notebooks");
|
||||
verifyIndex(data, db, "content", "content");
|
||||
verifyIndex(data, db, "attachments", "attachments");
|
||||
// verifyIndex(data, db, "trash", "trash");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ export const EVENTS = {
|
||||
mediaAttachmentDownloaded: "attachments:mediaDownloaded",
|
||||
};
|
||||
|
||||
export const CURRENT_DATABASE_VERSION = 5.2;
|
||||
export const CURRENT_DATABASE_VERSION = 5.3;
|
||||
|
||||
export function setUserPersonalizationBytes(userSalt) {
|
||||
USER_PERSONALIZATION_HASH = new Uint8Array(
|
||||
|
||||
@@ -92,12 +92,9 @@ export default class Backup {
|
||||
|
||||
switch (version) {
|
||||
case CURRENT_DATABASE_VERSION:
|
||||
case 5.0:
|
||||
case 5.1:
|
||||
case 4:
|
||||
case 4.1:
|
||||
case 4.2:
|
||||
case 4.3: {
|
||||
case 5.2:
|
||||
case 5.0: {
|
||||
return backup;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -1,32 +1,16 @@
|
||||
export const migrations = {
|
||||
4: {
|
||||
note: function (item) {
|
||||
if (item.notebooks && item.notebooks.every((n) => !n.id)) {
|
||||
item.notebooks = undefined;
|
||||
}
|
||||
return migrations["4.1"].note(item);
|
||||
},
|
||||
},
|
||||
4.1: {
|
||||
note: function (item) {
|
||||
return migrations["4.2"].note(item);
|
||||
},
|
||||
},
|
||||
4.2: {
|
||||
note: function (item) {
|
||||
if (item.notebooks) {
|
||||
item.notebooks = item.notebooks.map((nb) => {
|
||||
return { id: nb.id, topics: nb.topics || [nb.topic] };
|
||||
});
|
||||
}
|
||||
item.migrated = true;
|
||||
return item;
|
||||
},
|
||||
},
|
||||
4.3: {},
|
||||
5.0: {},
|
||||
5.1: {},
|
||||
5.2: {
|
||||
note: replaceDateEditedWithDateModified(),
|
||||
notebook: replaceDateEditedWithDateModified(),
|
||||
tag: replaceDateEditedWithDateModified(true),
|
||||
attachment: replaceDateEditedWithDateModified(true),
|
||||
trash: replaceDateEditedWithDateModified(),
|
||||
tiny: replaceDateEditedWithDateModified(),
|
||||
settings: replaceDateEditedWithDateModified(true),
|
||||
},
|
||||
5.3: {
|
||||
note: false,
|
||||
notebook: false,
|
||||
tag: false,
|
||||
@@ -36,3 +20,12 @@ export const migrations = {
|
||||
settings: false,
|
||||
},
|
||||
};
|
||||
|
||||
function replaceDateEditedWithDateModified(removeDateEditedProperty = false) {
|
||||
return function (item) {
|
||||
item.dateModified = item.dateEdited;
|
||||
if (removeDateEditedProperty) delete item.dateEdited;
|
||||
delete item.persistDateEdited;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "notes-core",
|
||||
"version": "6.15.0",
|
||||
"version": "6.16.0",
|
||||
"private": true,
|
||||
"main": "./api/index.js",
|
||||
"devDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user