IO-1551 Polling mode for unsupported browsers.

This commit is contained in:
Patrick Fic
2021-12-08 17:05:44 -08:00
parent 76ea8ca2ed
commit 58848481c9
9 changed files with 74 additions and 27 deletions

View File

@@ -46,11 +46,8 @@ export function ChatAffixContainer({ bodyshop, chatVisible }) {
<Space>
<Button
onClick={async () => {
const resp = await requestForToken();
console.log(
"🚀 ~ file: chat-affix.container.jsx ~ line 44 ~ resp",
resp
);
await requestForToken();
SubscribeToTopic();
}}
>
@@ -84,12 +81,17 @@ export function ChatAffixContainer({ bodyshop, chatVisible }) {
payload: (payload && payload.data && payload.data.data) || payload.data,
});
}
const stopMessageListenr = onMessage(messaging, handleMessage);
const channel = new BroadcastChannel("imex-sw-messages");
channel.addEventListener("message", handleMessage);
let stopMessageListenr, channel;
try {
stopMessageListenr = onMessage(messaging, handleMessage);
channel = new BroadcastChannel("imex-sw-messages");
channel.addEventListener("message", handleMessage);
} catch (error) {
console.log("Unable to set event listeners.");
}
return () => {
stopMessageListenr();
channel.removeEventListener("message", handleMessage);
stopMessageListenr && stopMessageListenr();
channel && channel.removeEventListener("message", handleMessage);
};
}, [client]);