Added manual conversation creation BOD-379

This commit is contained in:
Patrick Fic
2020-09-03 08:57:13 -07:00
parent 51b6a560a6
commit f3b32fae76
10 changed files with 123 additions and 15 deletions

View File

@@ -32,6 +32,7 @@ export function* onOpenChatByPhone() {
export function* openChatByPhone({ payload }) {
logImEXEvent("messaging_open_by_phone");
const { phone_num, jobid } = payload;
const bodyshop = yield select(selectBodyshop);
try {
const {
@@ -39,7 +40,9 @@ export function* openChatByPhone({ payload }) {
} = yield client.query({
query: CONVERSATION_ID_BY_PHONE,
variables: { phone: phone(phone_num)[0] },
fetchPolicy: "network-only",
});
if (conversations.length === 0) {
const {
data: {
@@ -61,13 +64,14 @@ export function* openChatByPhone({ payload }) {
} else if (conversations.length === 1) {
//got the ID. Open it.
yield put(setSelectedConversation(conversations[0].id));
yield client.mutate({
mutation: INSERT_CONVERSATION_TAG,
variables: {
conversationId: conversations[0].id,
jobId: jobid,
},
});
if (jobid)
yield client.mutate({
mutation: INSERT_CONVERSATION_TAG,
variables: {
conversationId: conversations[0].id,
jobId: jobid,
},
});
} else {
console.log("ERROR: Multiple conversations found. "); //TODO Graceful handling of this situation
}