diff --git a/web/src/lib/components/add-media-card.svelte b/web/src/lib/components/add-media-card.svelte index 268cebf..4026669 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, LoaderCircle } from 'lucide-svelte'; - import { goto, invalidateAll } from '$app/navigation'; + import { goto } from '$app/navigation'; import { resolve } from '$app/paths'; import type { components } from '$lib/api/api'; import client from '$lib/api'; @@ -13,7 +13,6 @@ result, isShow = true }: { result: components['schemas']['MetaDataProviderSearchResult']; isShow: boolean } = $props(); - console.log('Add Show Card Result: ', result); async function addMedia() { loading = true; @@ -41,11 +40,14 @@ } if (isShow) { - await goto(resolve('/dashboard/tv/[showId]', { showId: data?.id ?? '' })); + await goto(resolve('/dashboard/tv/[showId]', { showId: data?.id ?? '' }), { + invalidateAll: true + }); } else { - await goto(resolve('/dashboard/movies/[movieId]', { movieId: data?.id ?? '' })); + await goto(resolve('/dashboard/movies/[movieId]', { movieId: data?.id ?? '' }), { + invalidateAll: true + }); } - await invalidateAll(); loading = false; } diff --git a/web/src/lib/components/delete-media-dialog.svelte b/web/src/lib/components/delete-media-dialog.svelte index 997c0bf..837d881 100644 --- a/web/src/lib/components/delete-media-dialog.svelte +++ b/web/src/lib/components/delete-media-dialog.svelte @@ -26,15 +26,14 @@ toast.error('Movie ID is missing'); return; } - const { response } = await client.DELETE('/api/v1/movies/{movie_id}', { + const { error } = await client.DELETE('/api/v1/movies/{movie_id}', { params: { path: { movie_id: media.id }, query: { delete_files_on_disk: deleteFilesOnDisk, delete_torrents: deleteTorrents } } }); - if (!response.ok) { - const errorText = await response.text(); - toast.error('Failed to delete movie: ' + errorText); + if (error) { + toast.error('Failed to delete movie: ' + error.detail); } else { toast.success('Movie deleted successfully.'); deleteDialogOpen = false; @@ -43,15 +42,14 @@ } async function delete_show() { - const { response } = await client.DELETE('/api/v1/tv/shows/{show_id}', { + const { error } = await client.DELETE('/api/v1/tv/shows/{show_id}', { params: { path: { show_id: media.id! }, query: { delete_files_on_disk: deleteFilesOnDisk, delete_torrents: deleteTorrents } } }); - if (!response.ok) { - const errorText = await response.text(); - toast.error('Failed to delete show: ' + errorText); + if (error) { + toast.error('Failed to delete show: ' + error.detail); } else { toast.success('Show deleted successfully.'); deleteDialogOpen = false; diff --git a/web/src/lib/components/download-movie-dialog.svelte b/web/src/lib/components/download-movie-dialog.svelte index c45d545..c15324a 100644 --- a/web/src/lib/components/download-movie-dialog.svelte +++ b/web/src/lib/components/download-movie-dialog.svelte @@ -11,10 +11,11 @@ import * as Table from '$lib/components/ui/table/index.js'; import client from '$lib/api'; import SelectFilePathSuffixDialog from '$lib/components/select-file-path-suffix-dialog.svelte'; + import { invalidateAll } from '$app/navigation'; let { movie } = $props(); let dialogueState = $state(false); - let torrentsPromise: any = $state(); + let torrentsPromise: any = $state(null); let tabState: string = $state('basic'); let isLoading: boolean = $state(false); let advancedMode: boolean = $derived(tabState === 'advanced'); @@ -40,19 +41,16 @@ console.warn(errorMessage); torrentsError = errorMessage; if (dialogueState) toast.info(errorMessage); - return []; } else if (!response.ok) { const errorMessage = `Failed to download torrent for movie ${movie.id}: ${response.statusText}`; console.error(errorMessage); torrentsError = errorMessage; toast.error(errorMessage); - return false; } else { console.log('Downloading torrent:', data); toast.success('Torrent download started successfully!'); - - return true; } + await invalidateAll(); } async function search() { @@ -75,7 +73,7 @@ } - (dialogueState ? search() : null)}> + Download Movie @@ -170,9 +168,17 @@ {:else} - -
No torrents found.
-
+ {#if data === null} + +
+ Start searching by clicking the search button! +
+
+ {:else} + +
No torrents found.
+
+ {/if} {/each} diff --git a/web/src/lib/components/download-season-dialog.svelte b/web/src/lib/components/download-season-dialog.svelte index d0edeb5..5415488 100644 --- a/web/src/lib/components/download-season-dialog.svelte +++ b/web/src/lib/components/download-season-dialog.svelte @@ -12,6 +12,7 @@ import client from '$lib/api'; import type { components } from '$lib/api/api'; import SelectFilePathSuffixDialog from '$lib/components/select-file-path-suffix-dialog.svelte'; + import { invalidateAll } from '$app/navigation'; let { show }: { show: components['schemas']['Show'] } = $props(); let dialogueState = $state(false); @@ -41,17 +42,15 @@ console.warn(errorMessage); torrentsError = errorMessage; if (dialogueState) toast.info(errorMessage); - return false; } else if (!response.ok) { const errorMessage = `Failed to download torrent for show ${show.id} and season ${selectedSeasonNumber}: ${response.statusText}`; console.error(errorMessage); torrentsError = errorMessage; toast.error(errorMessage); - return false; } else { toast.success('Torrent download started successfully!'); - return true; } + await invalidateAll(); } async function search() { @@ -73,7 +72,7 @@ } - (dialogueState ? search() : null)}> + Download Seasons @@ -202,9 +201,17 @@ {:else} - -
No torrents found.
-
+ {#if data === null} + +
+ Start searching by clicking the search button! +
+
+ {:else} + +
No torrents found.
+
+ {/if} {/each} diff --git a/web/src/lib/components/edit-torrent-dialog.svelte b/web/src/lib/components/edit-torrent-dialog.svelte index 27cd318..0582c3a 100644 --- a/web/src/lib/components/edit-torrent-dialog.svelte +++ b/web/src/lib/components/edit-torrent-dialog.svelte @@ -14,11 +14,10 @@ torrent: components['schemas']['MovieTorrent'] | components['schemas']['RichSeasonTorrent']; } = $props(); let dialogOpen = $state(false); - let importedState = $state(torrent.imported || false); + let importedState = $derived(torrent.imported); async function closeDialog() { dialogOpen = false; - importedState = torrent.imported || false; } async function saveTorrent() { const { error } = await client.PATCH('/api/v1/torrent/{torrent_id}/status', { @@ -32,8 +31,7 @@ } }); if (error) { - console.error(`Failed to update torrent ${torrent.torrent_id} imported state: ${error}`); - toast.error(`Failed to update torrent: ${error}`); + toast.error('Failed to update torrent.'); return; } await invalidateAll(); @@ -53,10 +51,8 @@
+ -
diff --git a/web/src/lib/components/library-combobox.svelte b/web/src/lib/components/library-combobox.svelte index fb6c840..a5b5ac0 100644 --- a/web/src/lib/components/library-combobox.svelte +++ b/web/src/lib/components/library-combobox.svelte @@ -9,6 +9,7 @@ import { toast } from 'svelte-sonner'; import client from '$lib/api'; import type { components } from '$lib/api/api'; + import { invalidateAll } from '$app/navigation'; let { media, @@ -70,6 +71,7 @@ toast.success(`Library updated to ${selectedLabel}`); media.library = selectedLabel; } + await invalidateAll(); } function closeAndFocusTrigger() { diff --git a/web/src/lib/components/login-card.svelte b/web/src/lib/components/login-card.svelte index d3f2cbc..e82b4a2 100644 --- a/web/src/lib/components/login-card.svelte +++ b/web/src/lib/components/login-card.svelte @@ -5,7 +5,6 @@ import { Label } from '$lib/components/ui/label/index.js'; import { goto } from '$app/navigation'; import { toast } from 'svelte-sonner'; - import { base } from '$app/paths'; import * as Alert from '$lib/components/ui/alert/index.js'; import AlertCircleIcon from '@lucide/svelte/icons/alert-circle'; import LoadingBar from '$lib/components/loading-bar.svelte'; @@ -49,7 +48,7 @@ console.log('Received User Data: ', response); successMessage = 'Login successful! Redirecting...'; toast.success(successMessage); - goto(resolve('/dashboard', {})); + await goto(resolve('/dashboard', {})); } else { toast.error('Login failed!'); errorMessage = `Login failed! Please check your credentials and try again.`; @@ -127,7 +126,9 @@ > {/each}
- +
diff --git a/web/src/lib/components/media-picture.svelte b/web/src/lib/components/media-picture.svelte index a1cd074..5e766cd 100644 --- a/web/src/lib/components/media-picture.svelte +++ b/web/src/lib/components/media-picture.svelte @@ -4,7 +4,6 @@ const apiUrl = env.PUBLIC_API_URL; let { media } = $props(); - console.log('got media: ', media); diff --git a/web/src/lib/components/recommended-media-carousel.svelte b/web/src/lib/components/recommended-media-carousel.svelte index 5932d5d..95a552a 100644 --- a/web/src/lib/components/recommended-media-carousel.svelte +++ b/web/src/lib/components/recommended-media-carousel.svelte @@ -3,8 +3,8 @@ import { Skeleton } from '$lib/components/ui/skeleton'; import { Button } from '$lib/components/ui/button'; import { ChevronRight } from 'lucide-svelte'; - import { base } from '$app/paths'; import type { components } from '$lib/api/api'; + import { resolve } from '$app/paths'; let { media, @@ -31,12 +31,16 @@ {/each} {/if} {#if isShow} - {:else} - diff --git a/web/src/lib/components/request-movie-dialog.svelte b/web/src/lib/components/request-movie-dialog.svelte index 0d27661..d846227 100644 --- a/web/src/lib/components/request-movie-dialog.svelte +++ b/web/src/lib/components/request-movie-dialog.svelte @@ -8,6 +8,7 @@ import { toast } from 'svelte-sonner'; import client from '$lib/api'; import type { components } from '$lib/api/api'; + import { invalidateAll } from '$app/navigation'; let { movie }: { movie: components['schemas']['PublicMovie'] } = $props(); let dialogOpen = $state(false); @@ -44,6 +45,7 @@ } else { toast.error('Failed to submit request'); } + await invalidateAll(); } diff --git a/web/src/lib/components/season-requests-table.svelte b/web/src/lib/components/season-requests-table.svelte index bb3efde..10d1a10 100644 --- a/web/src/lib/components/season-requests-table.svelte +++ b/web/src/lib/components/season-requests-table.svelte @@ -7,7 +7,7 @@ import { getContext } from 'svelte'; import { Button } from '$lib/components/ui/button/index.js'; import { toast } from 'svelte-sonner'; - import { goto } from '$app/navigation'; + import { goto, invalidateAll } from '$app/navigation'; import { resolve } from '$app/paths'; import client from '$lib/api'; @@ -56,12 +56,6 @@ response = data.response; } if (response.ok) { - const requestIndex = requests.findIndex((r) => r.id === requestId); - if (requestIndex !== -1) { - let newAuthorizedStatus = !currentAuthorizedStatus; - requests[requestIndex]!.authorized = newAuthorizedStatus; - requests[requestIndex]!.authorized_by = newAuthorizedStatus ? user() : undefined; - } toast.success( `Request ${!currentAuthorizedStatus ? 'approved' : 'unapproved'} successfully.` ); @@ -70,6 +64,7 @@ console.error(`Failed to update request status ${response.statusText}`, errorText); toast.error(`Failed to update request status: ${response.statusText}`); } + await invalidateAll(); } async function deleteRequest(requestId: string) { @@ -101,16 +96,12 @@ response = data.response; } if (response.ok) { - // remove the request from the list - const index = requests.findIndex((r) => r.id === requestId); - if (index > -1) { - requests.splice(index, 1); - } toast.success('Request deleted successfully'); } else { console.error(`Failed to delete request ${response.statusText}`, await response.text()); toast.error('Failed to delete request'); } + await invalidateAll(); } diff --git a/web/src/lib/components/signup-card.svelte b/web/src/lib/components/signup-card.svelte index 09c3ae4..e1d4f8d 100644 --- a/web/src/lib/components/signup-card.svelte +++ b/web/src/lib/components/signup-card.svelte @@ -8,9 +8,9 @@ import AlertCircleIcon from '@lucide/svelte/icons/alert-circle'; import LoadingBar from '$lib/components/loading-bar.svelte'; import CheckCircle2Icon from '@lucide/svelte/icons/check-circle-2'; - import { base } from '$app/paths'; import { handleOauth } from '$lib/utils.ts'; import client from '$lib/api'; + import { resolve } from '$app/paths'; let email = $state(''); let password = $state(''); @@ -125,7 +125,7 @@ > {/each}
- +
diff --git a/web/src/lib/components/torrent-table.svelte b/web/src/lib/components/torrent-table.svelte index b45f10a..4ac61ec 100644 --- a/web/src/lib/components/torrent-table.svelte +++ b/web/src/lib/components/torrent-table.svelte @@ -13,6 +13,7 @@ import { toast } from 'svelte-sonner'; import DeleteTorrentDialog from '$lib/components/delete-torrent-dialog.svelte'; import EditTorrentDialog from '$lib/components/edit-torrent-dialog.svelte'; + import { invalidateAll } from '$app/navigation'; let { torrents, isShow = true @@ -42,6 +43,7 @@ console.log(`Successfully retried download for torrent ${torrent.torrent_title}`); toast.success('Trying to download torrent...'); } + await invalidateAll(); } diff --git a/web/src/lib/components/user-data-table.svelte b/web/src/lib/components/user-data-table.svelte index 4bdcc11..ef0a7ac 100644 --- a/web/src/lib/components/user-data-table.svelte +++ b/web/src/lib/components/user-data-table.svelte @@ -47,8 +47,8 @@ selectedUser = null; newPassword = ''; newEmail = ''; - await invalidateAll(); } + await invalidateAll(); } async function deleteUser() { @@ -68,8 +68,8 @@ toast.success(`User ${userToDelete.email} deleted successfully.`); deleteDialogOpen = false; userToDelete = null; - await invalidateAll(); } + await invalidateAll(); } diff --git a/web/src/lib/components/user-settings.svelte b/web/src/lib/components/user-settings.svelte index 12450cd..bd93e8e 100644 --- a/web/src/lib/components/user-settings.svelte +++ b/web/src/lib/components/user-settings.svelte @@ -5,6 +5,7 @@ import { Label } from '$lib/components/ui/label/index.js'; import { Input } from '$lib/components/ui/input/index.js'; import client from '$lib/api'; + import { invalidateAll } from '$app/navigation'; let newPassword: string = $state(''); let newEmail: string = $state(''); @@ -25,6 +26,7 @@ } newPassword = ''; newEmail = ''; + await invalidateAll(); } diff --git a/web/src/routes/dashboard/about/+page.svelte b/web/src/routes/dashboard/about/+page.svelte index ebd95ae..ad51693 100644 --- a/web/src/routes/dashboard/about/+page.svelte +++ b/web/src/routes/dashboard/about/+page.svelte @@ -2,7 +2,7 @@ import { Separator } from '$lib/components/ui/separator/index.js'; import * as Sidebar from '$lib/components/ui/sidebar/index.js'; import * as Breadcrumb from '$lib/components/ui/breadcrumb/index.js'; - import { base } from '$app/paths'; + import { resolve } from '$app/paths'; import logo from '$lib/images/logo.svg'; import { PUBLIC_VERSION } from '$env/static/public'; @@ -22,7 +22,11 @@ +