mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
working error handling
This commit is contained in:
1 parent
aeebec4a90
commit
9403edcb92
15 files changed
+267
-78
No files matched your search
@@ -3,10 +3,23 @@ import { messageState } from './state';
|
||||
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
|
||||
|
||||
|
||||
const NOTIFICATION_TIMEOUT = 6000;
|
||||
|
||||
export const useMessagesService = () => {
|
||||
const setMessageGroups = useSetRecoilState(messageState.messageGroups);
|
||||
const setMessages = useSetRecoilState(messageState.messages);
|
||||
const setCreateMessageGroupResult = useSetRecoilState(messageState.createMessageGroupResult);
|
||||
|
||||
const _handleCreateMessageGroupResult = (result) => {
|
||||
console.log(result);
|
||||
setCreateMessageGroupResult(result);
|
||||
window.setTimeout(() => {
|
||||
setCreateMessageGroupResult(null);
|
||||
}, NOTIFICATION_TIMEOUT);
|
||||
};
|
||||
|
||||
useNuiEvent('MESSAGES', 'phone:fetchMessageGroupsSuccess', setMessageGroups);
|
||||
useNuiEvent('MESSAGES', 'phone:fetchMessagesSuccess', setMessages);
|
||||
useNuiEvent('MESSAGES', 'phone:createMessageGroupSuccess', _handleCreateMessageGroupResult);
|
||||
useNuiEvent('MESSAGES', 'phone:createMessageGroupFailed', _handleCreateMessageGroupResult);
|
||||
}
|
||||
Reference in new issue
Block a user