16 lines
586 B
TypeScript
Raw Normal View History

2022-05-12 02:45:43 +08:00
import { fetchUserAccount } from '@/web/api/user'
2022-04-16 21:14:03 +08:00
import { UserApiNames, FetchUserAccountResponse } from '@/shared/api/User'
import { APIs } from '@/shared/CacheAPIs'
import { IpcChannels } from '@/shared/IpcChannels'
2022-08-03 23:48:39 +08:00
import { useQuery } from '@tanstack/react-query'
2022-03-13 14:40:38 +08:00
export default function useUser() {
2022-08-03 23:48:39 +08:00
return useQuery([UserApiNames.FetchUserAccount], fetchUserAccount, {
2022-03-13 14:40:38 +08:00
refetchOnWindowFocus: true,
2022-04-16 21:14:03 +08:00
placeholderData: (): FetchUserAccountResponse | undefined =>
2022-04-09 00:28:37 +08:00
window.ipcRenderer?.sendSync(IpcChannels.GetApiCacheSync, {
2022-04-16 21:14:03 +08:00
api: APIs.UserAccount,
2022-03-30 00:53:05 +08:00
}),
2022-03-13 14:40:38 +08:00
})
}