fix(phone/messages): change how we get source | remove useEffect for parts

This commit is contained in:
Christopher committed 2021-02-16 23:33:23 +01:00
1 parent be479d75cc
commit 15d7d3dcea
2 files changed
+5 -6

No files matched your search

@@ -19,8 +19,6 @@ const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
const [participants, setParticipants] = useState('');
const [label, setLabel] = useState('');
useEffect(() => phoneNumber && setParticipants(phoneNumber), [phoneNumber]);
// handles phone numbers in a csv format and strips all spaces and
// external characters out of them:
// 123-4567, 987-6543, 333-4444
@@ -37,7 +35,7 @@ const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
useEffect(() => {
if (phoneNumber) {
sendNuiCreateMessageGroup({ parts: getGroupParts(phoneNumber), isGroupChat: false, labelValue });
sendNuiCreateMessageGroup({ parts: getGroupParts(phoneNumber), isGroupChat: false, labelValue: null });
history.push('/messages');
}
}, [phoneNumber, labelValue, history, getGroupParts]);
+4 -3
View File
@@ -402,6 +402,7 @@ onNet(events.MESSAGES_FETCH_MESSAGE_GROUPS, async () => {
onNet(
events.MESSAGES_CREATE_MESSAGE_GROUP,
async (phoneNumbers: string[], label: string = null) => {
const pSource = (global as any).source;
try {
const _identifier = await useIdentifier();
const result = await createMessageGroupsFromPhoneNumbers(
@@ -413,18 +414,18 @@ onNet(
if (result.error) {
emitNet(
events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED,
getSource(),
pSource,
result
);
} else {
emitNet(
events.MESSAGES_CREATE_MESSAGE_GROUP_SUCCESS,
getSource(),
pSource,
result
);
}
} catch (e) {
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, getSource());
emitNet(events.MESSAGES_CREATE_MESSAGE_GROUP_FAILED, pSource);
messageLogger.error(`Failed to create message group, ${e.message}`);
}
}