Skip to content

Commit 1a1918a

Browse files
author
unknown
committed
nativeTree.load() default behavior fallback to original implementation: skipHash: boolean = false
1 parent 25060a8 commit 1a1918a

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/lib/native/NativeAccount.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ export default class NativeAccount extends Account {
2222
await this.storage.initMappings()
2323
await this.storage.initCache()
2424
const nativeTree = new NativeTree(this.storage)
25-
console.log("[NativeAccount/init]")
25+
console.log("[DebugLog_NativeAccount/init]")
2626
await nativeTree.load(true)
2727
this.localTree = nativeTree
2828
}
2929

3030
static async get(id:string):Promise<Account> {
31+
console.log("[DebugLog_NativeAccount/get]")
3132
const storage = new NativeAccountStorage(id)
3233
const data = await storage.getAccountData(null)
3334
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
3435
// @ts-ignore
3536
const tree = new NativeTree(storage)
36-
console.log("[NativeAccount/get]")
3737
//await tree.loadCachedHash()
3838
await tree.load(true)
3939
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -50,7 +50,7 @@ export default class NativeAccount extends Account {
5050
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
5151
// @ts-ignore
5252
const tree = new NativeTree(storage)
53-
console.log("[NativeAccount/create]")
53+
console.log("[DebugLog_NativeAccount/create]")
5454
await tree.load(true)
5555
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
5656
// @ts-ignore
@@ -132,6 +132,7 @@ export default class NativeAccount extends Account {
132132
}
133133

134134
static async getAllAccounts():Promise<Account[]> {
135+
console.log('[DebugLog_NativeAccount/getAllAccounts()]')
135136
return Promise.all(
136137
(await NativeAccountStorage.getAllAccounts()).map((accountId) =>
137138
Account.get(accountId)

src/lib/native/NativeTree.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class NativeTree extends CachingAdapter implements BulkImportReso
1919
}
2020

2121
// Load cached hash from persistent storage
22-
async loadCachedHash() {
22+
/* async loadCachedHash() {
2323
try {
2424
console.log("[NativeTree/loadCachedHash] load start")
2525
const { value: persistedHash } = await Storage.get({ key: `bookmarks[${this.accountId}].treeHash` })
@@ -38,10 +38,11 @@ export default class NativeTree extends CachingAdapter implements BulkImportReso
3838
console.log("[NativeTree/loadCachedHash] Failed, error")
3939
console.warn('Failed to load persisted hash, continuing without it', err)
4040
}
41-
}
41+
}*/
4242

4343
// loads the bookmarkTree from file, and parse it with JSON.parse(). This is where the android app is getting slow at launch
44-
async load(skipHash?: boolean):Promise<boolean> {
44+
async load(skipHash: boolean = false):Promise<boolean> {
45+
console.log("[DebugLog_NativeTree/load()]")
4546
const {value: tree} = await Storage.get({key: `bookmarks[${this.accountId}].tree`})
4647
const {value: highestId} = await Storage.get({key: `bookmarks[${this.accountId}].highestId`})
4748

@@ -67,6 +68,7 @@ export default class NativeTree extends CachingAdapter implements BulkImportReso
6768
}
6869

6970
async save():Promise<void> {
71+
console.log("[DebugLog_NativeTree/save()]")
7072
await Storage.set({key: `bookmarks[${this.accountId}].tree`, value: JSON.stringify(await this.bookmarksCache.cloneWithLocation(true, ItemLocation.LOCAL).toJSONAsync())})
7173
await Storage.set({key: `bookmarks[${this.accountId}].highestId`, value: this.highestId + ''})
7274
}
@@ -79,6 +81,7 @@ export default class NativeTree extends CachingAdapter implements BulkImportReso
7981
}
8082

8183
async getBookmarksTree(): Promise<Folder<typeof ItemLocation.LOCAL>> {
84+
console.log("[DebugLog_NativeTree/getBookmarksTree()]")
8285
const tree = await super.getBookmarksTree()
8386
tree.createIndex()
8487
return tree as Folder<typeof ItemLocation.LOCAL>

0 commit comments

Comments
 (0)