mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
refactor: migrate to theme-ui from rebass
This commit is contained in:
@@ -1,26 +1,27 @@
|
||||
/* This file is part of the Notesnook project (https://notesnook.com/)
|
||||
*
|
||||
* Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
databaseTest,
|
||||
TEST_NOTE,
|
||||
delay,
|
||||
StorageInterface,
|
||||
StorageInterface
|
||||
} from "../../../__tests__/utils";
|
||||
import Collector from "../collector";
|
||||
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/* This file is part of the Notesnook project (https://notesnook.com/)
|
||||
*
|
||||
* Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Database from "../../index";
|
||||
import { NodeStorageInterface } from "../../../__mocks__/node-storage.mock";
|
||||
@@ -52,10 +53,10 @@ test("case 3: Device A & B have unsynced changes but server has nothing", async
|
||||
const deviceB = await initializeDevice("deviceB");
|
||||
|
||||
const note1Id = await deviceA.notes.add({
|
||||
title: "Test note from device A",
|
||||
title: "Test note from device A"
|
||||
});
|
||||
const note2Id = await deviceB.notes.add({
|
||||
title: "Test note from device B",
|
||||
title: "Test note from device B"
|
||||
});
|
||||
|
||||
await syncAndWait(deviceA, deviceB);
|
||||
@@ -218,8 +219,8 @@ test("issue: colors are not properly created if multiple notes are synced togeth
|
||||
const id = await deviceA.notes.add({
|
||||
content: {
|
||||
type: "tiptap",
|
||||
data: `<p>deviceA=true</p>`,
|
||||
},
|
||||
data: `<p>deviceA=true</p>`
|
||||
}
|
||||
});
|
||||
noteIds.push(id);
|
||||
}
|
||||
@@ -287,7 +288,7 @@ test("issue: remove notebook reference from notes that are removed from topic du
|
||||
|
||||
const id = await deviceA.notebooks.add({
|
||||
title: "Notebook 1",
|
||||
topics: ["Topic 1"],
|
||||
topics: ["Topic 1"]
|
||||
});
|
||||
|
||||
await syncAndWait(deviceA, deviceB, false);
|
||||
@@ -334,7 +335,7 @@ async function initializeDevice(id, capabilities = []) {
|
||||
EV.subscribe(EVENTS.userCheckStatus, async (type) => {
|
||||
return {
|
||||
type,
|
||||
result: capabilities.indexOf(type) > -1,
|
||||
result: capabilities.indexOf(type) > -1
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/* This file is part of the Notesnook project (https://notesnook.com/)
|
||||
*
|
||||
* Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { checkIsUserPremium, CHECK_IDS, EVENTS } from "../../common";
|
||||
import { logger } from "../../logger";
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/* This file is part of the Notesnook project (https://notesnook.com/)
|
||||
*
|
||||
* Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { CURRENT_DATABASE_VERSION } from "../../common";
|
||||
import { logger } from "../../logger";
|
||||
@@ -44,7 +45,7 @@ class Collector {
|
||||
this._db.attachments.syncable,
|
||||
isForceSync
|
||||
),
|
||||
...this._collect("settings", [this._db.settings.raw], isForceSync),
|
||||
...this._collect("settings", [this._db.settings.raw], isForceSync)
|
||||
];
|
||||
|
||||
return { items, vaultKey: await this._db.vault._getKey() };
|
||||
@@ -80,7 +81,7 @@ class Collector {
|
||||
id: item.id,
|
||||
collectionId,
|
||||
deleted: true,
|
||||
dateModified: Date.now(),
|
||||
dateModified: Date.now()
|
||||
});
|
||||
} else if (isUnsynced && isSyncable) {
|
||||
prev.push({ ...item, collectionId });
|
||||
@@ -115,7 +116,7 @@ class Collector {
|
||||
return {
|
||||
id: item.id,
|
||||
v: CURRENT_DATABASE_VERSION,
|
||||
...(await this._serialize(item)),
|
||||
...(await this._serialize(item))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/* This file is part of the Notesnook project (https://notesnook.com/)
|
||||
*
|
||||
* Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
class Conflicts {
|
||||
/**
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
/* This file is part of the Notesnook project (https://notesnook.com/)
|
||||
*
|
||||
* Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
EV,
|
||||
EVENTS,
|
||||
sendAttachmentsProgressEvent,
|
||||
sendSyncProgressEvent,
|
||||
sendSyncProgressEvent
|
||||
} from "../../common";
|
||||
import Constants from "../../utils/constants";
|
||||
import TokenManager from "../token-manager";
|
||||
@@ -130,8 +131,8 @@ class Sync {
|
||||
case signalr.LogLevel.Warning:
|
||||
return scopedLogger.warn(message);
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
.withHubProtocol(new MessagePackHubProtocol({ ignoreUndefined: true }))
|
||||
.withAutomaticReconnect()
|
||||
@@ -178,7 +179,7 @@ class Sync {
|
||||
this.logger.info("Data collected for sync", {
|
||||
newLastSynced,
|
||||
length: data.items.length,
|
||||
isEmpty: data.items.length <= 0,
|
||||
isEmpty: data.items.length <= 0
|
||||
});
|
||||
|
||||
const serverResponse = full ? await this.fetch(lastSynced) : null;
|
||||
@@ -243,7 +244,7 @@ class Sync {
|
||||
});
|
||||
},
|
||||
complete: () => {},
|
||||
error: reject,
|
||||
error: reject
|
||||
});
|
||||
});
|
||||
|
||||
@@ -308,7 +309,7 @@ class Sync {
|
||||
current: i,
|
||||
total,
|
||||
items,
|
||||
types,
|
||||
types
|
||||
});
|
||||
|
||||
if (result) {
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/* This file is part of the Notesnook project (https://notesnook.com/)
|
||||
*
|
||||
* Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { migrations } from "../../migrations";
|
||||
import SparkMD5 from "spark-md5";
|
||||
@@ -36,17 +37,17 @@ class Merger {
|
||||
threshold: 1000,
|
||||
get: () => this._db.settings.raw,
|
||||
set: (item) => this._db.settings.merge(item),
|
||||
conflict: (_local, remote) => this._db.settings.merge(remote),
|
||||
conflict: (_local, remote) => this._db.settings.merge(remote)
|
||||
},
|
||||
note: {
|
||||
get: (id) => this._db.notes.note(id),
|
||||
set: (item) => this._db.notes.merge(item),
|
||||
set: (item) => this._db.notes.merge(item)
|
||||
},
|
||||
notebook: {
|
||||
threshold: 1000,
|
||||
get: (id) => this._db.notebooks.notebook(id),
|
||||
set: (item) => this._db.notebooks.merge(item),
|
||||
conflict: (_local, remote) => this._db.notebooks.merge(remote),
|
||||
conflict: (_local, remote) => this._db.notebooks.merge(remote)
|
||||
},
|
||||
content: {
|
||||
threshold: process.env.NODE_ENV === "test" ? 6 * 1000 : 60 * 1000,
|
||||
@@ -79,7 +80,7 @@ class Merger {
|
||||
await this._db.notes.add({ id: local.noteId, conflicted: true });
|
||||
await this._db.storage.write("hasConflicts", true);
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
attachment: {
|
||||
set: async (item) => {
|
||||
@@ -111,12 +112,12 @@ class Merger {
|
||||
);
|
||||
}
|
||||
await this._db.attachments.merge(remoteAttachment);
|
||||
},
|
||||
}
|
||||
},
|
||||
vaultKey: {
|
||||
set: async (vaultKey) =>
|
||||
this._db.vault._setKey(await this._deserialize(vaultKey, false)),
|
||||
},
|
||||
this._db.vault._setKey(await this._deserialize(vaultKey, false))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -203,7 +204,7 @@ class Merger {
|
||||
isModified,
|
||||
timeDiff,
|
||||
remote: remoteItem.dateModified,
|
||||
local: localItem.dateModified,
|
||||
local: localItem.dateModified
|
||||
});
|
||||
|
||||
await markAsConflicted(localItem, remoteItem);
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/* This file is part of the Notesnook project (https://notesnook.com/)
|
||||
*
|
||||
* Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import set from "../../utils/set";
|
||||
import { qclone } from "qclone";
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
/* This file is part of the Notesnook project (https://notesnook.com/)
|
||||
*
|
||||
* Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
This file is part of the Notesnook project (https://notesnook.com/)
|
||||
|
||||
Copyright (C) 2022 Streetwriters (Private) Limited
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function areAllEmpty(obj) {
|
||||
for (let key in obj) {
|
||||
|
||||
Reference in New Issue
Block a user