Fix some storage bugs

This commit is contained in:
Jon Staab
2025-09-30 17:04:52 -07:00
parent a8d1c4bbbc
commit 483fa81b74
3 changed files with 11 additions and 9 deletions

View File

@@ -138,7 +138,10 @@ const syncTracker = async () => {
const updateAll = throttle(3000, () => {
p = p.then(() => {
collectionStorageProvider.set("tracker", Array.from(tracker.relaysById.entries()))
collectionStorageProvider.set(
"tracker",
Array.from(tracker.relaysById.entries()).map(([id, relays]) => [id, Array.from(relays)]),
)
})
})

View File

@@ -1,4 +1,3 @@
import {parseJson} from "@welshman/lib"
import {type StorageProvider} from "@welshman/store"
import {Preferences} from "@capacitor/preferences"
import {Encoding, Filesystem, Directory} from "@capacitor/filesystem"
@@ -44,10 +43,10 @@ export class CollectionStorageProvider implements StorageProvider {
const items: T[] = []
for (const line of file.data.toString().split("\n")) {
const item = parseJson(line)
if (item) {
items.push(item)
try {
items.push(JSON.parse(line))
} catch (e) {
// pass
}
}
@@ -77,7 +76,7 @@ export class CollectionStorageProvider implements StorageProvider {
path: key + ".json",
directory: Directory.Data,
encoding: Encoding.UTF8,
data: value.map(v => JSON.stringify(v)).join("\n"),
data: "\n" + value.map(v => JSON.stringify(v)).join("\n"),
})
})
@@ -98,7 +97,7 @@ export class CollectionStorageProvider implements StorageProvider {
),
)
} catch (e) {
// Directory might not have been created
// Directory might not have been created yet
}
})

View File

@@ -89,7 +89,7 @@
import NewNotificationSound from "@src/app/components/NewNotificationSound.svelte"
// Migration: delete old indexeddb database
indexedDB?.deleteDatabase('flotilla')
indexedDB?.deleteDatabase("flotilla")
// Migration: old nostrtalk instance used different sessions
if ($session && !$signer) {