mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
mobile: add support for offline mode, backup with attachments
This commit is contained in:
committed by
Abdullah Atta
parent
b6021dc76b
commit
d12ed967e3
@@ -254,7 +254,7 @@ class Database {
|
||||
this.sql().withTables(),
|
||||
new NNMigrationProvider()
|
||||
);
|
||||
await this.onInit(this.sql() as Kysely<RawDatabaseSchema>);
|
||||
await this.onInit(this.sql() as unknown as Kysely<RawDatabaseSchema>);
|
||||
await this.initCollections();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ import { DefaultColors } from "../../collections/colors";
|
||||
export type SyncOptions = {
|
||||
type: "full" | "fetch" | "send";
|
||||
force?: boolean;
|
||||
offlineMode?: boolean;
|
||||
};
|
||||
|
||||
export default class SyncManager {
|
||||
@@ -246,7 +247,7 @@ class Sync {
|
||||
await this.db.setLastSynced(Date.now());
|
||||
this.db.eventManager.publish(EVENTS.syncCompleted);
|
||||
|
||||
if (await this.db.kv().read("fullOfflineMode")) {
|
||||
if (options.offlineMode) {
|
||||
const attachments = await this.db.attachments.linked
|
||||
.fields(["attachments.id", "attachments.hash", "attachments.chunkSize"])
|
||||
.items();
|
||||
|
||||
@@ -33,6 +33,7 @@ export class Crypto {
|
||||
|
||||
export function isCipher(item: any): item is Cipher<"base64"> {
|
||||
return (
|
||||
item !== null &&
|
||||
typeof item === "object" &&
|
||||
"cipher" in item &&
|
||||
"iv" in item &&
|
||||
|
||||
Reference in New Issue
Block a user