From e76e01df46bdf20b538c02caa2d7592d2cf3255c Mon Sep 17 00:00:00 2001
From: ThaUnknown <6506529+ThaUnknown@users.noreply.github.com>
Date: Tue, 29 Jul 2025 22:03:52 +0200
Subject: [PATCH] feat: add safety checks to loading last torrent
---
package.json | 2 +-
src/lib/components/ui/sidebar/sidebarlist.svelte | 10 +++++-----
.../components/ui/torrentclient/library/table.svelte | 3 ++-
src/lib/modules/torrent/client.ts | 1 +
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/package.json b/package.json
index f333bdb..ddb0567 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ui",
- "version": "6.4.95",
+ "version": "6.4.96",
"license": "BUSL-1.1",
"private": true,
"packageManager": "pnpm@9.15.5",
diff --git a/src/lib/components/ui/sidebar/sidebarlist.svelte b/src/lib/components/ui/sidebar/sidebarlist.svelte
index 31dba93..f08ed00 100644
--- a/src/lib/components/ui/sidebar/sidebarlist.svelte
+++ b/src/lib/components/ui/sidebar/sidebarlist.svelte
@@ -3,7 +3,7 @@
import Heart from 'lucide-svelte/icons/heart'
import House from 'lucide-svelte/icons/house'
import LogIn from 'lucide-svelte/icons/log-in'
- // import MessagesSquare from 'lucide-svelte/icons/messages-square'
+ import MessagesSquare from 'lucide-svelte/icons/messages-square'
import Play from 'lucide-svelte/icons/play'
import Search from 'lucide-svelte/icons/search'
import Settings from 'lucide-svelte/icons/settings'
@@ -59,9 +59,9 @@
-
+
@@ -71,8 +71,8 @@
-
-
+
+
{#if hasAuth}
{@const viewer = client.profile()}
diff --git a/src/lib/components/ui/torrentclient/library/table.svelte b/src/lib/components/ui/torrentclient/library/table.svelte
index ab94b32..dda6d38 100644
--- a/src/lib/components/ui/torrentclient/library/table.svelte
+++ b/src/lib/components/ui/torrentclient/library/table.svelte
@@ -67,7 +67,8 @@
async function playEntry ({ mediaID, episode, hash }: LibraryEntry) {
if (!mediaID || !hash) return
const media = await client.single(mediaID)
- server.play(hash, media.data!.Media!, episode)
+ if (!media.data?.Media) return // TODO: log this?
+ server.play(hash, media.data.Media, episode)
goto('/app/player/')
}
diff --git a/src/lib/modules/torrent/client.ts b/src/lib/modules/torrent/client.ts
index cc4b25d..d5447cd 100644
--- a/src/lib/modules/torrent/client.ts
+++ b/src/lib/modules/torrent/client.ts
@@ -77,6 +77,7 @@ export const server = new class ServerClient {
}
play (id: string, media: Media, episode: number) {
+ if (!media || !id) return
debug('playing torrent', id, media.id, episode)
this.last.set({ id, media, episode })
this.active.value = this._play(id, media, episode)