feat: allow loading mods without a Steam API key
Add fetchModFromUrl/fetchModFileFromUrl and accept a fileUrl query param on /items routes so the frontend can download saves directly from a search result's file_url, with no key required.
This commit is contained in:
@@ -4,26 +4,28 @@ import { fetchMod } from '../api';
|
||||
|
||||
interface ModState {
|
||||
id: string | null;
|
||||
fileUrl?: string;
|
||||
mod: TTSMod | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
load: (id: string) => Promise<void>;
|
||||
load: (id: string, fileUrl?: string) => Promise<void>;
|
||||
clear: () => void;
|
||||
}
|
||||
|
||||
export const useModStore = create<ModState>((set) => ({
|
||||
id: null,
|
||||
fileUrl: undefined,
|
||||
mod: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
load: async (id) => {
|
||||
set({ loading: true, error: null, id });
|
||||
load: async (id, fileUrl) => {
|
||||
set({ loading: true, error: null, id, fileUrl });
|
||||
try {
|
||||
const mod = await fetchMod(id);
|
||||
const mod = await fetchMod(id, fileUrl);
|
||||
set({ mod, loading: false });
|
||||
} catch (err) {
|
||||
set({ loading: false, error: String(err) });
|
||||
}
|
||||
},
|
||||
clear: () => set({ id: null, mod: null, error: null, loading: false }),
|
||||
clear: () => set({ id: null, fileUrl: undefined, mod: null, error: null, loading: false }),
|
||||
}));
|
||||
Reference in New Issue
Block a user