mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-24 05:29:51 +03:00
warm up the cache on mount
This commit is contained in:
parent
6b147d4d25
commit
20c03d6e96
@ -62,7 +62,7 @@ export const listFiles = async (params: {
|
||||
|
||||
const sessionsCache: Record<string, Promise<Session[]>> = {};
|
||||
|
||||
const list = async (params: { projectId: string; earliestTimestampMs?: number }) => {
|
||||
export const list = async (params: { projectId: string; earliestTimestampMs?: number }) => {
|
||||
if (params.projectId in sessionsCache) {
|
||||
return sessionsCache[params.projectId].then((sessions) =>
|
||||
sessions.filter((s) =>
|
||||
|
@ -4,10 +4,11 @@
|
||||
import { Toaster } from 'svelte-french-toast';
|
||||
import type { LayoutData } from './$types';
|
||||
import { BackForwardButtons } from '$lib/components';
|
||||
import { setContext } from 'svelte';
|
||||
import { onMount, setContext } from 'svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import Breadcrumbs from '$lib/components/Breadcrumbs.svelte';
|
||||
import CommandPalette from '$lib/components/CommandPalette';
|
||||
import { list as listSessions, listFiles } from '$lib/sessions';
|
||||
|
||||
export let data: LayoutData;
|
||||
const { user, posthog, projects } = data;
|
||||
@ -16,6 +17,16 @@
|
||||
setContext('session', writable(null));
|
||||
setContext('projects', projects);
|
||||
|
||||
onMount(() =>
|
||||
// warm up the cache
|
||||
$projects.forEach(async (project) => {
|
||||
const sessions = await listSessions({ projectId: project.id });
|
||||
sessions.forEach(async (session) => {
|
||||
listFiles({ projectId: project.id, sessionId: session.id });
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
user.subscribe(posthog.identify);
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user