From ab61bf31280f5e3784fbaac408809c2fcea8b61e Mon Sep 17 00:00:00 2001 From: Taso Date: Wed, 8 Dec 2021 15:48:27 -0500 Subject: [PATCH] tweak(phone/messages): remove dead code flow --- .../apps/messages/hooks/useMessageService.ts | 59 ++++++++----------- typings/messages.ts | 9 --- 2 files changed, 25 insertions(+), 43 deletions(-) diff --git a/phone/src/apps/messages/hooks/useMessageService.ts b/phone/src/apps/messages/hooks/useMessageService.ts index 6f0449b29..7de51a13f 100644 --- a/phone/src/apps/messages/hooks/useMessageService.ts +++ b/phone/src/apps/messages/hooks/useMessageService.ts @@ -1,22 +1,15 @@ import { useNuiEvent } from 'fivem-nui-react-lib'; -import { - Message, - MessageConversationResponse, - MessageEvents, -} from '@typings/messages'; -import { useMessageActions } from './useMessageActions'; -import { useCallback } from 'react'; +import { MessageEvents } from '@typings/messages'; import { useMessageNotifications } from './useMessageNotifications'; import { useLocation } from 'react-router'; import { usePhoneVisibility } from '@os/phone/hooks/usePhoneVisibility'; -import { useContactActions } from '../../contacts/hooks/useContactActions'; export const useMessagesService = () => { - const { updateMessages, updateConversations } = useMessageActions(); + // const { updateMessages, updateConversations } = useMessageActions(); const { setNotification } = useMessageNotifications(); const { pathname } = useLocation(); const { visibility } = usePhoneVisibility(); - const { getContactByNumber } = useContactActions(); + // const { getContactByNumber } = useContactActions(); const handleMessageBroadcast = ({ conversationName, conversationId, message }) => { if (visibility && pathname.includes('/messages/conversations')) { @@ -26,30 +19,28 @@ export const useMessagesService = () => { setNotification({ conversationName, conversationId, message }); }; - // This is only called for the receiver of the message. We'll be using the standardized pattern for the transmitter. - const handleUpdateMessages = useCallback( - (messageDto: Message) => { - updateMessages(messageDto); - }, - [updateMessages], - ); - - const handleAddConversation = useCallback( - (conversation: MessageConversationResponse) => { - const contact = getContactByNumber(conversation.phoneNumber); - - updateConversations({ - phoneNumber: conversation.phoneNumber, - conversation_id: conversation.conversation_id, - avatar: contact.avatar || null, - unread: 0, - display: contact.display || null, - }); - }, - [updateConversations, getContactByNumber], - ); + // // This is only called for the receiver of the message. We'll be using the standardized pattern for the transmitter. + // const handleUpdateMessages = useCallback( + // (messageDto: Message) => { + // updateMessages(messageDto); + // }, + // [updateMessages], + // ); + // + // const handleAddConversation = useCallback( + // (conversation: MessageConversationResponse) => { + // const contact = getContactByNumber(conversation.phoneNumber); + // + // updateConversations({ + // phoneNumber: conversation.phoneNumber, + // conversation_id: conversation.conversation_id, + // avatar: contact.avatar || null, + // unread: 0, + // display: contact.display || null, + // }); + // }, + // [updateConversations, getContactByNumber], + // ); useNuiEvent('MESSAGES', MessageEvents.CREATE_MESSAGE_BROADCAST, handleMessageBroadcast); - useNuiEvent('MESSAGES', MessageEvents.SEND_MESSAGE_SUCCESS, handleUpdateMessages); - useNuiEvent('MESSAGES', MessageEvents.CREATE_MESSAGE_CONVERSATION_SUCCESS, handleAddConversation); }; diff --git a/typings/messages.ts b/typings/messages.ts index 1f97121f3..67cbff120 100644 --- a/typings/messages.ts +++ b/typings/messages.ts @@ -82,19 +82,10 @@ export interface MessageConversationResponse { export enum MessageEvents { FETCH_MESSAGE_CONVERSATIONS = 'npwd:fetchMessageGroups', - FETCH_MESSAGE_GROUPS_SUCCESS = 'npwd:fetchMessageGroupsSuccess', - FETCH_MESSAGE_GROUPS_FAILED = 'npwd:fetchMessageGroupsFailed', CREATE_MESSAGE_CONVERSATION = 'npwd:createMessageGroup', - CREATE_MESSAGE_CONVERSATION_SUCCESS = 'npwd:createMessageConversationSuccess', - CREATE_MESSAGE_GROUP_SUCCESS = 'npwd:createMessageGroupSuccess', - CREATE_MESSAGE_GROUP_FAILED = 'npwd:createMessageGroupFailed', SEND_MESSAGE = 'npwd:sendMessage', - SEND_MESSAGE_SUCCESS = 'npwd:sendMessageSuccess', - SEND_MESSAGE_FAILED = 'npwd:sendMessageFailed', DELETE_MESSAGE = 'npwd:deleteMessage', FETCH_MESSAGES = 'npwd:fetchMessages', - FETCH_MESSAGES_SUCCESS = 'npwd:fetchMessagesSuccess', - FETCH_MESSAGES_FAILED = 'npwd:fetchMessagesFailed', FETCH_INITIAL_MESSAGES = 'npwd:fetchInitialMessages', ACTION_RESULT = 'npwd:setMessagesAlert', CREATE_MESSAGE_BROADCAST = 'createMessagesBroadcast',