fix: cache preload

feat: Fetch only newest relay list updates
This commit is contained in:
2023-05-25 10:31:47 +01:00
parent 2ccee7bd7c
commit 988416f353
13 changed files with 79 additions and 51 deletions

View File

@ -32,6 +32,9 @@ import Thread from "Element/Thread";
import { SubscribeRoutes } from "Pages/subscribe";
import ZapPoolPage from "Pages/ZapPool";
import DebugPage from "Pages/Debug";
import { db } from "Db";
import { preload } from "Cache";
import { LoginStore } from "Login";
// @ts-ignore
window.__webpack_nonce__ = "ZmlhdGphZiBzYWlkIHNub3J0LnNvY2lhbCBpcyBwcmV0dHkgZ29vZCwgd2UgbWFkZSBpdCE=";
@ -42,6 +45,25 @@ export const router = createBrowserRouter([
{
element: <Layout />,
errorElement: <ErrorPage />,
loader: async () => {
db.ready = await db.isAvailable();
if (db.ready) {
await preload(LoginStore.takeSnapshot().follows.item);
}
try {
if ("registerProtocolHandler" in window.navigator) {
window.navigator.registerProtocolHandler(
"web+nostr",
`${window.location.protocol}//${window.location.host}/%s`
);
console.info("Registered protocol handler for 'web+nostr'");
}
} catch (e) {
console.error("Failed to register protocol handler", e);
}
return null;
},
children: [
...RootRoutes,
{