pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

remove old feb token store and just use auth

Pas e81bdbc3 11925822

+4 -43
+4 -12
src/components/player/hooks/useSkipTime.ts
··· 2 2 3 3 import { usePlayerMeta } from "@/components/player/hooks/usePlayerMeta"; 4 4 import { conf } from "@/setup/config"; 5 - 6 - const getUserToken = (): string | null => { 7 - try { 8 - return typeof window !== "undefined" 9 - ? window.localStorage.getItem("febbox_ui_token") 10 - : null; 11 - } catch (e) { 12 - console.warn("Unable to access localStorage:", e); 13 - return null; 14 - } 15 - }; 5 + import { useAuthStore } from "@/stores/auth"; 16 6 17 7 // Thanks Nemo for this API 18 8 const BASE_URL = "https://skips.pstream.org"; ··· 21 11 export function useSkipTime() { 22 12 const { playerMeta: meta } = usePlayerMeta(); 23 13 const [skiptime, setSkiptime] = useState<number | null>(null); 14 + const febboxToken = useAuthStore((s) => s.febboxToken); 24 15 25 16 useEffect(() => { 26 17 const fetchSkipTime = async (retries = 0): Promise<void> => { 27 18 if (!meta?.imdbId || meta.type === "movie") return; 28 19 if (!conf().ALLOW_FEBBOX_KEY) return; 29 - if (!getUserToken()) return; 20 + if (!febboxToken) return; 30 21 31 22 try { 32 23 const apiUrl = `${BASE_URL}/${meta.imdbId}/${meta.season?.number}/${meta.episode?.number}`; ··· 66 57 meta?.type, 67 58 meta?.season?.number, 68 59 meta?.episode?.number, 60 + febboxToken, 69 61 ]); 70 62 71 63 return skiptime;
-31
src/stores/auth/index.ts
··· 64 64 set((s) => { 65 65 s.febboxToken = token; 66 66 }); 67 - try { 68 - if (token === null) { 69 - localStorage.removeItem("febbox_ui_token"); 70 - } else { 71 - localStorage.setItem("febbox_ui_token", token); 72 - } 73 - } catch (e) { 74 - console.warn("Failed to access localStorage:", e); 75 - } 76 67 }, 77 68 setAccountProfile(profile) { 78 69 set((s) => { ··· 99 90 })), 100 91 { 101 92 name: "__MW::auth", 102 - migrate: (persistedState: any) => { 103 - // Migration from localStorage to Zustand store 104 - if (!persistedState.febboxToken) { 105 - try { 106 - const storedToken = localStorage.getItem("febbox_ui_token"); 107 - if (storedToken) persistedState.febboxToken = storedToken; 108 - } catch (e) { 109 - console.warn("LocalStorage access failed during migration:", e); 110 - } 111 - } 112 - return persistedState; 113 - }, 114 - onRehydrateStorage: () => (state) => { 115 - // After store rehydration 116 - if (state?.febboxToken) { 117 - try { 118 - localStorage.setItem("febbox_ui_token", state.febboxToken); 119 - } catch (e) { 120 - console.warn("Failed to sync token to localStorage:", e); 121 - } 122 - } 123 - }, 124 93 }, 125 94 ), 126 95 );