mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-20 03:32:06 +00:00
remove old feb token store and just use auth
This commit is contained in:
parent
1192582263
commit
e81bdbc322
2 changed files with 4 additions and 43 deletions
|
|
@ -2,17 +2,7 @@ import { useEffect, useState } from "react";
|
|||
|
||||
import { usePlayerMeta } from "@/components/player/hooks/usePlayerMeta";
|
||||
import { conf } from "@/setup/config";
|
||||
|
||||
const getUserToken = (): string | null => {
|
||||
try {
|
||||
return typeof window !== "undefined"
|
||||
? window.localStorage.getItem("febbox_ui_token")
|
||||
: null;
|
||||
} catch (e) {
|
||||
console.warn("Unable to access localStorage:", e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
|
||||
// Thanks Nemo for this API
|
||||
const BASE_URL = "https://skips.pstream.org";
|
||||
|
|
@ -21,12 +11,13 @@ const MAX_RETRIES = 3;
|
|||
export function useSkipTime() {
|
||||
const { playerMeta: meta } = usePlayerMeta();
|
||||
const [skiptime, setSkiptime] = useState<number | null>(null);
|
||||
const febboxToken = useAuthStore((s) => s.febboxToken);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchSkipTime = async (retries = 0): Promise<void> => {
|
||||
if (!meta?.imdbId || meta.type === "movie") return;
|
||||
if (!conf().ALLOW_FEBBOX_KEY) return;
|
||||
if (!getUserToken()) return;
|
||||
if (!febboxToken) return;
|
||||
|
||||
try {
|
||||
const apiUrl = `${BASE_URL}/${meta.imdbId}/${meta.season?.number}/${meta.episode?.number}`;
|
||||
|
|
@ -66,6 +57,7 @@ export function useSkipTime() {
|
|||
meta?.type,
|
||||
meta?.season?.number,
|
||||
meta?.episode?.number,
|
||||
febboxToken,
|
||||
]);
|
||||
|
||||
return skiptime;
|
||||
|
|
|
|||
|
|
@ -64,15 +64,6 @@ export const useAuthStore = create(
|
|||
set((s) => {
|
||||
s.febboxToken = token;
|
||||
});
|
||||
try {
|
||||
if (token === null) {
|
||||
localStorage.removeItem("febbox_ui_token");
|
||||
} else {
|
||||
localStorage.setItem("febbox_ui_token", token);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Failed to access localStorage:", e);
|
||||
}
|
||||
},
|
||||
setAccountProfile(profile) {
|
||||
set((s) => {
|
||||
|
|
@ -99,28 +90,6 @@ export const useAuthStore = create(
|
|||
})),
|
||||
{
|
||||
name: "__MW::auth",
|
||||
migrate: (persistedState: any) => {
|
||||
// Migration from localStorage to Zustand store
|
||||
if (!persistedState.febboxToken) {
|
||||
try {
|
||||
const storedToken = localStorage.getItem("febbox_ui_token");
|
||||
if (storedToken) persistedState.febboxToken = storedToken;
|
||||
} catch (e) {
|
||||
console.warn("LocalStorage access failed during migration:", e);
|
||||
}
|
||||
}
|
||||
return persistedState;
|
||||
},
|
||||
onRehydrateStorage: () => (state) => {
|
||||
// After store rehydration
|
||||
if (state?.febboxToken) {
|
||||
try {
|
||||
localStorage.setItem("febbox_ui_token", state.febboxToken);
|
||||
} catch (e) {
|
||||
console.warn("Failed to sync token to localStorage:", e);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue