Merged in release/2021-12-10 (pull request #295)
release/2021-12-10 Approved-by: Patrick Fic
This commit is contained in:
@@ -29927,6 +29927,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>nopush</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>phonenumber</name>
|
<name>phonenumber</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ firebase.initializeApp(firebaseConfig);
|
|||||||
const messaging = firebase.messaging();
|
const messaging = firebase.messaging();
|
||||||
|
|
||||||
messaging.onBackgroundMessage(function (payload) {
|
messaging.onBackgroundMessage(function (payload) {
|
||||||
console.log("FCM BG MSG", payload);
|
|
||||||
// Customize notification here
|
// Customize notification here
|
||||||
const channel = new BroadcastChannel("imex-sw-messages");
|
const channel = new BroadcastChannel("imex-sw-messages");
|
||||||
channel.postMessage(payload);
|
channel.postMessage(payload);
|
||||||
|
|||||||
@@ -46,11 +46,8 @@ export function ChatAffixContainer({ bodyshop, chatVisible }) {
|
|||||||
<Space>
|
<Space>
|
||||||
<Button
|
<Button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const resp = await requestForToken();
|
await requestForToken();
|
||||||
console.log(
|
|
||||||
"🚀 ~ file: chat-affix.container.jsx ~ line 44 ~ resp",
|
|
||||||
resp
|
|
||||||
);
|
|
||||||
SubscribeToTopic();
|
SubscribeToTopic();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -84,12 +81,17 @@ export function ChatAffixContainer({ bodyshop, chatVisible }) {
|
|||||||
payload: (payload && payload.data && payload.data.data) || payload.data,
|
payload: (payload && payload.data && payload.data.data) || payload.data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const stopMessageListenr = onMessage(messaging, handleMessage);
|
let stopMessageListenr, channel;
|
||||||
const channel = new BroadcastChannel("imex-sw-messages");
|
try {
|
||||||
channel.addEventListener("message", handleMessage);
|
stopMessageListenr = onMessage(messaging, handleMessage);
|
||||||
|
channel = new BroadcastChannel("imex-sw-messages");
|
||||||
|
channel.addEventListener("message", handleMessage);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Unable to set event listeners.");
|
||||||
|
}
|
||||||
return () => {
|
return () => {
|
||||||
stopMessageListenr();
|
stopMessageListenr && stopMessageListenr();
|
||||||
channel.removeEventListener("message", handleMessage);
|
channel && channel.removeEventListener("message", handleMessage);
|
||||||
};
|
};
|
||||||
}, [client]);
|
}, [client]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
import {
|
import {
|
||||||
ShrinkOutlined,
|
|
||||||
InfoCircleOutlined,
|
InfoCircleOutlined,
|
||||||
|
MessageOutlined,
|
||||||
|
ShrinkOutlined,
|
||||||
SyncOutlined,
|
SyncOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
|
import { useQuery } from "@apollo/client";
|
||||||
import { Col, Row, Tooltip, Space, Typography, Badge, Card } from "antd";
|
import { Badge, Card, Col, Row, Space, Tag, Tooltip, Typography } from "antd";
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { CONVERSATION_LIST_QUERY } from "../../graphql/conversations.queries";
|
||||||
import { toggleChatVisible } from "../../redux/messaging/messaging.actions";
|
import { toggleChatVisible } from "../../redux/messaging/messaging.actions";
|
||||||
import ChatConversationListComponent from "../chat-conversation-list/chat-conversation-list.component";
|
|
||||||
import ChatConversationContainer from "../chat-conversation/chat-conversation.container";
|
|
||||||
import {
|
import {
|
||||||
selectChatVisible,
|
selectChatVisible,
|
||||||
selectSelectedConversation,
|
selectSelectedConversation,
|
||||||
} from "../../redux/messaging/messaging.selectors";
|
} from "../../redux/messaging/messaging.selectors";
|
||||||
import "./chat-popup.styles.scss";
|
import ChatConversationListComponent from "../chat-conversation-list/chat-conversation-list.component";
|
||||||
|
import ChatConversationContainer from "../chat-conversation/chat-conversation.container";
|
||||||
import ChatNewConversation from "../chat-new-conversation/chat-new-conversation.component";
|
import ChatNewConversation from "../chat-new-conversation/chat-new-conversation.component";
|
||||||
import { CONVERSATION_LIST_QUERY } from "../../graphql/conversations.queries";
|
|
||||||
import { useQuery } from "@apollo/client";
|
|
||||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||||
import { MessageOutlined } from "@ant-design/icons";
|
import "./chat-popup.styles.scss";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
selectedConversation: selectSelectedConversation,
|
selectedConversation: selectSelectedConversation,
|
||||||
@@ -37,11 +36,20 @@ export function ChatPopupComponent({
|
|||||||
toggleChatVisible,
|
toggleChatVisible,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [pollInterval, setpollInterval] = useState(0);
|
||||||
|
const { loading, data, refetch, called } = useQuery(CONVERSATION_LIST_QUERY, {
|
||||||
|
...(pollInterval > 0 ? { pollInterval } : {}),
|
||||||
|
});
|
||||||
|
|
||||||
const { loading, data, refetch, called } = useQuery(
|
const fcmToken = sessionStorage.getItem("fcmtoken");
|
||||||
CONVERSATION_LIST_QUERY,
|
|
||||||
{}
|
useEffect(() => {
|
||||||
);
|
if (fcmToken) {
|
||||||
|
setpollInterval(0);
|
||||||
|
} else {
|
||||||
|
setpollInterval(60000);
|
||||||
|
}
|
||||||
|
}, [fcmToken]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (called && chatVisible) refetch();
|
if (called && chatVisible) refetch();
|
||||||
@@ -71,6 +79,9 @@ export function ChatPopupComponent({
|
|||||||
style={{ cursor: "pointer" }}
|
style={{ cursor: "pointer" }}
|
||||||
onClick={() => refetch()}
|
onClick={() => refetch()}
|
||||||
/>
|
/>
|
||||||
|
{pollInterval > 0 && (
|
||||||
|
<Tag color="yellow">{t("messaging.labels.nopush")}</Tag>
|
||||||
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
<ShrinkOutlined
|
<ShrinkOutlined
|
||||||
onClick={() => toggleChatVisible()}
|
onClick={() => toggleChatVisible()}
|
||||||
|
|||||||
@@ -38,8 +38,14 @@ export const updateCurrentPassword = async (password) => {
|
|||||||
|
|
||||||
return updatePassword(currentUser, password);
|
return updatePassword(currentUser, password);
|
||||||
};
|
};
|
||||||
|
let messaging;
|
||||||
|
try {
|
||||||
|
messaging = getMessaging();
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
|
||||||
export const messaging = getMessaging();
|
export { messaging };
|
||||||
|
|
||||||
export const requestForToken = () => {
|
export const requestForToken = () => {
|
||||||
return getToken(messaging, {
|
return getToken(messaging, {
|
||||||
@@ -48,6 +54,7 @@ export const requestForToken = () => {
|
|||||||
.then((currentToken) => {
|
.then((currentToken) => {
|
||||||
if (currentToken) {
|
if (currentToken) {
|
||||||
console.log("current token for client: ", currentToken);
|
console.log("current token for client: ", currentToken);
|
||||||
|
window.sessionStorage.setItem("fcmtoken", currentToken);
|
||||||
// Perform any other necessary action with the token
|
// Perform any other necessary action with the token
|
||||||
} else {
|
} else {
|
||||||
// Show permission request UI
|
// Show permission request UI
|
||||||
|
|||||||
@@ -185,7 +185,11 @@ export function Manage({ match, conflict, bodyshop }) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const widgetId = "IABVNO4scRKY11XBQkNr";
|
const widgetId = "IABVNO4scRKY11XBQkNr";
|
||||||
window.noticeable.render("widget", widgetId);
|
window.noticeable.render("widget", widgetId);
|
||||||
requestForToken();
|
try {
|
||||||
|
requestForToken();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Unable to request for token.", error);
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -1766,6 +1766,7 @@
|
|||||||
"messaging": "Messaging",
|
"messaging": "Messaging",
|
||||||
"noallowtxt": "This customer has not indicated their permission to be messaged.",
|
"noallowtxt": "This customer has not indicated their permission to be messaged.",
|
||||||
"nojobs": "Not associated to any job.",
|
"nojobs": "Not associated to any job.",
|
||||||
|
"nopush": "Polling Mode Enabled",
|
||||||
"phonenumber": "Phone #",
|
"phonenumber": "Phone #",
|
||||||
"presets": "Presets",
|
"presets": "Presets",
|
||||||
"recentonly": "Only your most recent 50 conversations will be shown here. If you are looking for an older conversation, find the related contact and click their phone number to view the conversation.",
|
"recentonly": "Only your most recent 50 conversations will be shown here. If you are looking for an older conversation, find the related contact and click their phone number to view the conversation.",
|
||||||
|
|||||||
@@ -1766,6 +1766,7 @@
|
|||||||
"messaging": "Mensajería",
|
"messaging": "Mensajería",
|
||||||
"noallowtxt": "",
|
"noallowtxt": "",
|
||||||
"nojobs": "",
|
"nojobs": "",
|
||||||
|
"nopush": "",
|
||||||
"phonenumber": "",
|
"phonenumber": "",
|
||||||
"presets": "",
|
"presets": "",
|
||||||
"recentonly": "",
|
"recentonly": "",
|
||||||
|
|||||||
@@ -1766,6 +1766,7 @@
|
|||||||
"messaging": "Messagerie",
|
"messaging": "Messagerie",
|
||||||
"noallowtxt": "",
|
"noallowtxt": "",
|
||||||
"nojobs": "",
|
"nojobs": "",
|
||||||
|
"nopush": "",
|
||||||
"phonenumber": "",
|
"phonenumber": "",
|
||||||
"presets": "",
|
"presets": "",
|
||||||
"recentonly": "",
|
"recentonly": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user