15 lines
540 B
TypeScript
Raw Normal View History

2022-04-16 21:14:03 +08:00
import { fetchUserAccount } from '@/renderer/api/user'
import { UserApiNames, FetchUserAccountResponse } from '@/shared/api/User'
import { APIs } from '@/shared/CacheAPIs'
import { IpcChannels } from '@/shared/IpcChannels'
2022-03-13 14:40:38 +08:00
export default function useUser() {
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
})
}