mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
fix(calls): fix references to async selector DialerHistory
This commit is contained in:
1 parent
36d1e993bd
commit
10c5e97088
15 files changed
+61
-67
No files matched your search
@@ -1,9 +1,29 @@
|
||||
import { atom } from 'recoil';
|
||||
import { CallHistoryItem } from '../../../../../typings/call';
|
||||
import { atom, selector } from 'recoil';
|
||||
import { CallEvents, CallHistoryItem } from '../../../../../typings/call';
|
||||
import { fetchNui } from '../../../utils/fetchNui';
|
||||
import { ServerPromiseResp } from '../../../../../typings/common';
|
||||
import LogDebugEvent from '../../../os/debug/LogDebugEvents';
|
||||
import { isEnvBrowser } from '../../../utils/misc';
|
||||
import { MockHistoryData } from '../utils/constants';
|
||||
|
||||
export const dialState = {
|
||||
history: atom<CallHistoryItem[]>({
|
||||
key: 'dialHistory',
|
||||
default: [],
|
||||
default: selector({
|
||||
key: 'dialHistoryDefault',
|
||||
get: async () => {
|
||||
try {
|
||||
const resp = await fetchNui<ServerPromiseResp<CallHistoryItem[]>>(CallEvents.FETCH_CALLS);
|
||||
LogDebugEvent({ action: 'ContactsFetched', data: resp.data });
|
||||
return resp.data;
|
||||
} catch (e) {
|
||||
if (isEnvBrowser()) {
|
||||
return MockHistoryData;
|
||||
}
|
||||
console.error(e);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
}),
|
||||
}),
|
||||
};
|
||||
Reference in new issue
Block a user