mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 10:57:04 +00:00
Fix some storage bugs
This commit is contained in:
@@ -138,7 +138,10 @@ const syncTracker = async () => {
|
|||||||
|
|
||||||
const updateAll = throttle(3000, () => {
|
const updateAll = throttle(3000, () => {
|
||||||
p = p.then(() => {
|
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)]),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import {parseJson} from "@welshman/lib"
|
|
||||||
import {type StorageProvider} from "@welshman/store"
|
import {type StorageProvider} from "@welshman/store"
|
||||||
import {Preferences} from "@capacitor/preferences"
|
import {Preferences} from "@capacitor/preferences"
|
||||||
import {Encoding, Filesystem, Directory} from "@capacitor/filesystem"
|
import {Encoding, Filesystem, Directory} from "@capacitor/filesystem"
|
||||||
@@ -44,10 +43,10 @@ export class CollectionStorageProvider implements StorageProvider {
|
|||||||
|
|
||||||
const items: T[] = []
|
const items: T[] = []
|
||||||
for (const line of file.data.toString().split("\n")) {
|
for (const line of file.data.toString().split("\n")) {
|
||||||
const item = parseJson(line)
|
try {
|
||||||
|
items.push(JSON.parse(line))
|
||||||
if (item) {
|
} catch (e) {
|
||||||
items.push(item)
|
// pass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +76,7 @@ export class CollectionStorageProvider implements StorageProvider {
|
|||||||
path: key + ".json",
|
path: key + ".json",
|
||||||
directory: Directory.Data,
|
directory: Directory.Data,
|
||||||
encoding: Encoding.UTF8,
|
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) {
|
} catch (e) {
|
||||||
// Directory might not have been created
|
// Directory might not have been created yet
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
import NewNotificationSound from "@src/app/components/NewNotificationSound.svelte"
|
import NewNotificationSound from "@src/app/components/NewNotificationSound.svelte"
|
||||||
|
|
||||||
// Migration: delete old indexeddb database
|
// Migration: delete old indexeddb database
|
||||||
indexedDB?.deleteDatabase('flotilla')
|
indexedDB?.deleteDatabase("flotilla")
|
||||||
|
|
||||||
// Migration: old nostrtalk instance used different sessions
|
// Migration: old nostrtalk instance used different sessions
|
||||||
if ($session && !$signer) {
|
if ($session && !$signer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user