diff --git a/web/src/lib/components/add-media-card.svelte b/web/src/lib/components/add-media-card.svelte
index 5bd5e77..c3b172d 100644
--- a/web/src/lib/components/add-media-card.svelte
+++ b/web/src/lib/components/add-media-card.svelte
@@ -2,7 +2,7 @@
import { Button } from '$lib/components/ui/button/index.js';
import * as Card from '$lib/components/ui/card/index.js';
import { ImageOff } from 'lucide-svelte';
- import { goto } from '$app/navigation';
+ import {goto, invalidateAll} from '$app/navigation';
import { resolve } from '$app/paths';
import type { components } from '$lib/api/api';
import client from '$lib/api';
@@ -39,12 +39,14 @@
});
data = response.data;
}
- if (isShow) {
- await goto(resolve('/dashboard/tv/[showId]', { showId: data?.id ?? '' }));
+
+ if (isShow) {
+ await goto(resolve('/dashboard/tv/[showId]', {showId: data?.id ?? ''}));
} else {
- await goto(resolve('/dashboard/movies/[movieId]', { movieId: data?.id ?? '' }));
+ await goto(resolve('/dashboard/movies/[movieId]', {movieId: data?.id ?? ''}));
}
- loading = false;
+ await invalidateAll()
+ loading = false;
}
diff --git a/web/src/routes/dashboard/+layout.ts b/web/src/routes/dashboard/+layout.ts
index ac9dfbe..9759e27 100644
--- a/web/src/routes/dashboard/+layout.ts
+++ b/web/src/routes/dashboard/+layout.ts
@@ -6,9 +6,9 @@ import { goto } from '$app/navigation';
import client from '$lib/api';
export const load: LayoutLoad = async ({ fetch }) => {
- const { data, response } = await client.GET('/api/v1/users/me', { fetch: fetch });
+ const { data, error } = await client.GET('/api/v1/users/me', { fetch: fetch });
- if (!response.ok) {
+ if (error) {
console.log('unauthorized, redirecting to login');
if (browser) {
await goto(resolve('/login', {}));
@@ -16,5 +16,9 @@ export const load: LayoutLoad = async ({ fetch }) => {
throw redirect(303, resolve('/login', {}));
}
}
- return { user: data };
+ return {
+ user: data,
+ tvShows: await client.GET('/api/v1/tv/shows', { fetch: fetch }).then(res => res.data),
+ movies: await client.GET('/api/v1/movies', { fetch: fetch }).then(res => res.data),
+ };
};
diff --git a/web/src/routes/dashboard/movies/+page.svelte b/web/src/routes/dashboard/movies/+page.svelte
index 29c6bc5..a221e03 100644
--- a/web/src/routes/dashboard/movies/+page.svelte
+++ b/web/src/routes/dashboard/movies/+page.svelte
@@ -1,85 +1,90 @@
- Movies - MediaManager
-
+ Movies - MediaManager
+
-
-
-
-
-
-
- MediaManager
-
-
-
- Home
-
-
-
- Movies
-
-
-
-
+
+
+
+
+
+
+ MediaManager
+
+
+
+ Home
+
+
+
+ Movies
+
+
+
+
-
- {#if importableMovies().length > 0}
-
- {#each importableMovies() as importable (importable.directory)}
-
-
- Import movie
-
-
- {/each}
-
- {/if}
-
-
+
+ {#if importableMovies().length > 0}
+
+ {#each importableMovies() as importable (importable.directory)}
+
+
+ Import movie
+
+
+ {/each}
+
+ {/if}
+ {#await data.movies}
+
+ {:then movies}
+
+ {/await}
diff --git a/web/src/routes/dashboard/movies/+page.ts b/web/src/routes/dashboard/movies/+page.ts
deleted file mode 100644
index bfbcbc0..0000000
--- a/web/src/routes/dashboard/movies/+page.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type { PageLoad } from './$types';
-import client from '$lib/api';
-
-export const load: PageLoad = async ({ fetch }) => {
- const movies = await client.GET('/api/v1/movies', { fetch: fetch });
-
- return { movies: movies.data };
-};
diff --git a/web/src/routes/dashboard/tv/+page.svelte b/web/src/routes/dashboard/tv/+page.svelte
index 5faad5a..b5207e8 100644
--- a/web/src/routes/dashboard/tv/+page.svelte
+++ b/web/src/routes/dashboard/tv/+page.svelte
@@ -1,86 +1,92 @@
- TV Shows - MediaManager
-
+ TV Shows - MediaManager
+
-
-
-
-
-
-
- MediaManager
-
-
-
- Home
-
-
-
- Shows
-
-
-
-
+
+
+
+
+
+
+ MediaManager
+
+
+
+ Home
+
+
+
+ Shows
+
+
+
+
-
- {#if importableShows().length > 0}
-
- {#each importableShows() as importable (importable.directory)}
-
-
- Import TV show
-
-
- {/each}
-
- {/if}
-
+
+ {#if importableShows().length > 0}
+
+ {#each importableShows() as importable (importable.directory)}
+
+
+ Import TV show
+
+
+ {/each}
+
+ {/if}
+ {#await data.tvShows}
+
+ {:then tvShows}
+
+ {/await}
diff --git a/web/src/routes/dashboard/tv/+page.ts b/web/src/routes/dashboard/tv/+page.ts
deleted file mode 100644
index f892673..0000000
--- a/web/src/routes/dashboard/tv/+page.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import client from '$lib/api';
-import type { PageLoad } from './$types';
-
-export const load: PageLoad = async ({ fetch }) => {
- const tvShows = await client.GET('/api/v1/tv/shows', { fetch: fetch });
-
- return { tvShows: tvShows.data };
-};