feat: replace browser login with imported Reddit sessions
This commit is contained in:
1 parent
2b0545afcf
commit
c483c7b8be
76 files changed
+2048
-2828
No files matched your search
@@ -1,10 +1,9 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import type { ConfigResponse } from '../../../../../packages/api-contracts/src/index.js';
|
||||
import { fetchLoginInfo, fetchLoginStatus, fetchSettings, saveSettings, startLogin } from './settings-api.js';
|
||||
import { fetchLoginStatus, fetchSettings, importRedditSession, saveSettings } from './settings-api.js';
|
||||
|
||||
export const settingsQueryKeys = {
|
||||
config: ['dashboard', 'config'] as const,
|
||||
loginInfo: ['dashboard', 'login', 'info'] as const,
|
||||
loginStatus: ['dashboard', 'login', 'status'] as const,
|
||||
};
|
||||
|
||||
@@ -26,18 +25,14 @@ export function useSaveSettingsMutation() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useLoginInfoQuery() {
|
||||
return useQuery({ queryKey: settingsQueryKeys.loginInfo, queryFn: fetchLoginInfo });
|
||||
}
|
||||
|
||||
export function useLoginStatusQuery() {
|
||||
return useQuery({ queryKey: settingsQueryKeys.loginStatus, queryFn: fetchLoginStatus });
|
||||
}
|
||||
|
||||
export function useStartLoginMutation() {
|
||||
export function useImportRedditSessionMutation() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: startLogin,
|
||||
mutationFn: importRedditSession,
|
||||
onSuccess() {
|
||||
void queryClient.invalidateQueries({ queryKey: settingsQueryKeys.loginStatus });
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user