From fb61cb2257928ee92f2478baaf9f55bb12ffd00f Mon Sep 17 00:00:00 2001 From: bryantgillespie Date: Wed, 1 Apr 2026 14:03:05 -0400 Subject: [PATCH] refactor: robustify bunny TV chat feature - Extract shows data to shared util (bunnyShows.ts) - Fix WS lifecycle: persist across navigation, destroy on app:unmount - Add message dedup to prevent subscription echo - Add loading=lazy to thumbnails - Fix player/chat height with CSS min() constraint - Remove unused .disclaimer CSS --- app/composables/useBunnyChat.ts | 8 ++- app/pages/tv/bunny/[video].vue | 108 +++++--------------------------- app/pages/tv/bunny/index.vue | 100 +++-------------------------- app/plugins/tv.ts | 8 +++ app/utils/bunnyShows.ts | 97 ++++++++++++++++++++++++++++ 5 files changed, 134 insertions(+), 187 deletions(-) create mode 100644 app/utils/bunnyShows.ts diff --git a/app/composables/useBunnyChat.ts b/app/composables/useBunnyChat.ts index 74396d36..feec91e9 100644 --- a/app/composables/useBunnyChat.ts +++ b/app/composables/useBunnyChat.ts @@ -113,7 +113,9 @@ async function init(tvUrl: string, tvToken: string) { const items: ChatMessage[] = (message as any).data ?? []; for (const item of items) { - messages.value.push(item); + if (!messages.value.some((m) => m.id === item.id)) { + messages.value.push(item); + } } } })(); @@ -147,6 +149,8 @@ async function send(text: string, url: string) { }); } +export { destroy }; + export function useBunnyChat() { const { public: { tvUrl, tvToken }, @@ -154,5 +158,5 @@ export function useBunnyChat() { onMounted(() => init(tvUrl as string, tvToken as string)); - return { messages, handle, visitorId, isConnected, send, destroy }; + return { messages, handle, visitorId, isConnected, send }; } diff --git a/app/pages/tv/bunny/[video].vue b/app/pages/tv/bunny/[video].vue index fd89bca8..4af356d6 100644 --- a/app/pages/tv/bunny/[video].vue +++ b/app/pages/tv/bunny/[video].vue @@ -1,97 +1,12 @@