mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
tweak(phone/snackbar-provider): Altered API to expect a string for message, not a key (#135)
Change SnackbarProviderAlert message property to allow for any string rather than a explicit translation key
This commit is contained in:
10 files changed
+87
-19
No files matched your search
@@ -1,8 +1,10 @@
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
import { messageState } from './state';
|
||||
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
|
||||
import { useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||
import { IAlert, useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useMessageNotifications } from './useMessageNotifications';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
export const useMessagesService = () => {
|
||||
const setMessageGroups = useSetRecoilState(messageState.messageGroups);
|
||||
@@ -10,11 +12,22 @@ export const useMessagesService = () => {
|
||||
const setCreateMessageGroupResult = useSetRecoilState(messageState.createMessageGroupResult);
|
||||
const { addAlert } = useSnackbar();
|
||||
const { setNotification } = useMessageNotifications();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleAddAlert = useCallback(
|
||||
({ message, type }: IAlert) => {
|
||||
addAlert({
|
||||
message: t(`APPS_${message}`),
|
||||
type,
|
||||
});
|
||||
},
|
||||
[addAlert, t],
|
||||
);
|
||||
|
||||
useNuiEvent('MESSAGES', 'phone:fetchMessageGroupsSuccess', setMessageGroups);
|
||||
useNuiEvent('MESSAGES', 'phone:fetchMessagesSuccess', setMessages);
|
||||
useNuiEvent('MESSAGES', 'phone:createMessageGroupSuccess', setCreateMessageGroupResult);
|
||||
useNuiEvent('MESSAGES', 'phone:createMessageGroupFailed', setCreateMessageGroupResult);
|
||||
useNuiEvent('MESSAGES', 'phone:setMessagesAlert', addAlert);
|
||||
useNuiEvent('MESSAGES', 'createMessagesBroadcast', setNotification);
|
||||
useNuiEvent('MESSAGES', 'phone:setMessagesAlert', handleAddAlert);
|
||||
};
|
||||
Reference in new issue
Block a user