fix(calls): fix references to async selector DialerHistory

This commit is contained in:
Taso committed 2021-07-28 14:26:01 -04:00
1 parent 36d1e993bd
commit 10c5e97088
15 files changed
+61 -67

No files matched your search

+23 -3
View File
@@ -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 [];
}
},
}),
}),
};