mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
core: make sure all tests are passing
This commit is contained in:
committed by
Abdullah Atta
parent
fb26229715
commit
a700787cf3
@@ -26,11 +26,14 @@ export default class Content extends Collection {
|
||||
async add(content) {
|
||||
if (!content) return;
|
||||
|
||||
if (
|
||||
!!content.data &&
|
||||
(!!content.data.data || (!content.data.iv && !content.data.cipher))
|
||||
) {
|
||||
if (content.data.data && content.data.data.length)
|
||||
if (content.remote)
|
||||
throw new Error(
|
||||
"Please do not use this method for merging. Instead add the item directly to database."
|
||||
);
|
||||
if (content.deleted) return await this._collection.addItem(content);
|
||||
|
||||
if (typeof content.data === "object") {
|
||||
if (typeof content.data.data === "string")
|
||||
content.data = content.data.data;
|
||||
else if (!content.data.iv && !content.data.cipher)
|
||||
content.data = `<p>Content is invalid: ${JSON.stringify(
|
||||
|
||||
@@ -66,10 +66,14 @@ class Migrator {
|
||||
);
|
||||
|
||||
if (migrated || restore) {
|
||||
if (collection.dbCollection.merge) {
|
||||
if (collection.type === "settings") {
|
||||
await collection.dbCollection.merge(item);
|
||||
} else if (collection.dbCollection.add) {
|
||||
await collection.dbCollection.add(item);
|
||||
} else if (collection.dbCollection._collection) {
|
||||
await collection.dbCollection._collection?.addItem(item);
|
||||
} else {
|
||||
throw new Error(
|
||||
`No idea how to handle this kind of item: ${item.type}.`
|
||||
);
|
||||
}
|
||||
|
||||
// if id changed after migration, we need to delete the old one.
|
||||
|
||||
Reference in New Issue
Block a user