fix: Fixed romm login, now uses token
feat: Moved romm to internal plugin fix: Made focusing and navigation more reliable fix: Loading errors on first time launch
This commit is contained in:
parent
7c10f4e4c2
commit
816d50ae4d
81 changed files with 1659 additions and 1097 deletions
|
|
@ -22,16 +22,21 @@ export const gameQuery = (source: string, id: string) => queryOptions({
|
|||
return data;
|
||||
},
|
||||
});
|
||||
export const rommLogoutMutation = mutationOptions({ mutationKey: ["romm", "auth", "logout"], mutationFn: () => rommApi.api.romm.logout.post() });
|
||||
export const rommLogoutMutation = mutationOptions({ mutationKey: ["romm", "auth", "logout"], mutationFn: () => rommApi.api.romm.logout.romm.post() });
|
||||
export const rommQrLoginMutation = mutationOptions({
|
||||
mutationKey: ['login', 'qr', 'cancel'],
|
||||
mutationFn: () => rommApi.api.romm.login.romm.post()
|
||||
mutationFn: async () =>
|
||||
{
|
||||
const { data, error } = await rommApi.api.romm.login.romm.qr.post();
|
||||
if (error) throw error;
|
||||
return data;
|
||||
}
|
||||
});
|
||||
export const rommLoginMutation = mutationOptions({
|
||||
mutationKey: ["romm", "login"],
|
||||
mutationFn: async (data: z.infer<typeof RommLoginDataSchema>) =>
|
||||
{
|
||||
const { error } = await rommApi.api.romm.login.post({ username: data.username, password: data.password, host: data.hostname });
|
||||
const { error } = await rommApi.api.romm.login.romm.post({ username: data.username, password: data.password, host: data.hostname });
|
||||
if (error) throw error;
|
||||
},
|
||||
onSuccess: (d, v, r, c) =>
|
||||
|
|
@ -43,9 +48,14 @@ export const rommLoginMutation = mutationOptions({
|
|||
console.error(e);
|
||||
},
|
||||
});
|
||||
export const rommUserQuery = () => queryOptions({
|
||||
...getCurrentUserApiUsersMeGetOptions(),
|
||||
queryKey: ['romm', 'auth', "login"] as any,
|
||||
export const rommUserQuery = queryOptions({
|
||||
queryKey: ['romm', 'auth', "login"],
|
||||
queryFn: async () =>
|
||||
{
|
||||
const { data, error } = await rommApi.api.romm.user.romm.get();
|
||||
if (error) throw error;
|
||||
return data;
|
||||
},
|
||||
refetchOnWindowFocus: false,
|
||||
retry: 0
|
||||
});
|
||||
|
|
@ -54,19 +64,39 @@ export const rommGetOptionsQuery = () => queryOptions({
|
|||
refetchInterval: 30000,
|
||||
retry: false,
|
||||
});
|
||||
export const rommHasPasswordQuery = queryOptions({ queryKey: ['romm', 'auth', 'passLength'], queryFn: () => rommApi.api.romm.login.get().then(d => d.data?.hasPassword as boolean) });
|
||||
export const rommLoggedInQuery = queryOptions({
|
||||
queryKey: ['romm', 'auth', 'passLength'], queryFn: async () =>
|
||||
{
|
||||
const { data, error } = await rommApi.api.romm.login.romm.get();
|
||||
if (error) throw error;
|
||||
return data;
|
||||
}
|
||||
});
|
||||
export const rommHostnameQuery = queryOptions({ queryKey: ['romm', 'auth', 'hostname'], queryFn: () => settingsApi.api.settings({ id: 'rommAddress' }).get().then(d => d.data?.value as string) });
|
||||
export const rommUsernameQuery = queryOptions({ queryKey: ['romm', 'auth', 'username'], queryFn: () => settingsApi.api.settings({ id: 'rommUser' }).get().then(d => d.data?.value as string) });
|
||||
export const deleteGameMutation = (id: FrontEndId) => mutationOptions({
|
||||
mutationKey: ['delete', id],
|
||||
mutationFn: () => rommApi.api.romm.game({ source: id.source })({ id: id.id }).delete()
|
||||
});
|
||||
export const getCollectionsQuery = () => queryOptions({
|
||||
...getCollectionsApiCollectionsGetOptions(),
|
||||
export const getCollectionsQuery = queryOptions({
|
||||
queryKey: ['collections', 'all'],
|
||||
queryFn: async () =>
|
||||
{
|
||||
const { data, error } = await rommApi.api.romm.collections.get();
|
||||
if (error) throw error;
|
||||
return data;
|
||||
},
|
||||
refetchOnWindowFocus: false,
|
||||
staleTime: DefaultRommStaleTime
|
||||
});
|
||||
export const getCollectionQuery = (id: number) => queryOptions({ ...getCollectionApiCollectionsIdGetOptions({ path: { id } }) });
|
||||
export const getCollectionQuery = (source: string, id: string) => queryOptions({
|
||||
queryKey: ['collection', source, id], queryFn: async () =>
|
||||
{
|
||||
const { data, error } = await rommApi.api.romm.collection({ source })({ id }).get();
|
||||
if (error) throw error;
|
||||
return data;
|
||||
}, staleTime: DefaultRommStaleTime
|
||||
});
|
||||
export const platformQuery = (source: string, id: string) => queryOptions({
|
||||
queryKey: ['platform', source, id], queryFn: async () =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ export const storeFeaturedGamesQuery = queryOptions({
|
|||
return data;
|
||||
}
|
||||
});
|
||||
export const storeEmulatorsRecommendedQuery = queryOptions({
|
||||
queryKey: ['store-emulators', 'recommended'], queryFn: async () =>
|
||||
export const storeEmulatorsRecommendedQuery = (id?: string) => queryOptions({
|
||||
queryKey: ['store-emulators', 'recommended', id ?? 'all'], queryFn: async () =>
|
||||
{
|
||||
const { data, error } = await storeApi.api.store.emulators.get({ query: { limit: 6, missing: true, orderBy: 'importance' } });
|
||||
const { data, error } = await storeApi.api.store.emulators.get({ query: { limit: 6, missing: true, orderBy: 'importance', related: id } });
|
||||
if (error) throw error;
|
||||
return data;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue