Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/game/server/messages/messages.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class _MessagesService {
return resp({
status: 'error',
errorMsg: 'MESSAGES.FEEDBACK.MESSAGE_CONVERSATION_DUPLICATE',
data: { id: await this.messagesDB.getConversationId(conversationList) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the pattern and call async function outside of the resp function

});
} else {
const conversationId = await this.messagesDB.addParticipantToConversation(
Expand Down
9 changes: 4 additions & 5 deletions apps/phone/src/apps/messages/hooks/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ export const messageState = {

return messageConversations.filter((messageConversation) => {
for (const contact of contactsValue) {
if (
searchRegex.test(contact.display) &&
messageConversation.conversationList.includes(contact.number)
)
return true;
if (messageConversation.conversationList.includes(contact.number)) {
if (searchRegex.test(contact.display) || searchRegex.test(contact.number))
return true;
}
}

return searchRegex.test(messageConversation.label);
Expand Down
14 changes: 8 additions & 6 deletions apps/phone/src/apps/messages/hooks/useMessageAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useHistory } from 'react-router-dom';
import { messageState, useSetMessages } from './state';
import { useRecoilValueLoadable } from 'recoil';
import { MockConversationServerResp } from '../utils/constants';
import useMessages from './useMessages';
import { useMyPhoneNumber } from '@os/simcard/hooks/useMyPhoneNumber';

type UseMessageAPIProps = {
Expand All @@ -41,6 +42,7 @@ export const useMessageAPI = (): UseMessageAPIProps => {
const { state: messageConversationsState, contents: messageConversationsContents } =
useRecoilValueLoadable(messageState.messageCoversations);
const setMessages = useSetMessages();
const { goToConversation } = useMessages();

const myPhoneNumber = useMyPhoneNumber();

Expand Down Expand Up @@ -130,6 +132,7 @@ export const useMessageAPI = (): UseMessageAPIProps => {
return;
}


fetchNui<ServerPromiseResp<MessageConversation>, PreDBConversation>(
MessageEvents.CREATE_MESSAGE_CONVERSATION,
{
Expand All @@ -139,15 +142,14 @@ export const useMessageAPI = (): UseMessageAPIProps => {
},
).then((resp) => {
if (resp.status !== 'ok') {
history.push('/messages');

if (resp.errorMsg === 'MESSAGES.FEEDBACK.MESSAGE_CONVERSATION_DUPLICATE') {
return addAlert({
message: t('MESSAGES.FEEDBACK.MESSAGE_CONVERSATION_DUPLICATE'),
type: 'error',
});
if (resp.data) {
goToConversation(resp.data);
return
}
}

history.push('/messages');
return addAlert({
message: t('MESSAGE_CONVERSATION_CREATE_ONE_NUMBER_FAILED"', {
number: conversation.conversationLabel,
Expand Down