From d1e83fcee264586a7a6d1ce600e267539b662f1c Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Tue, 6 Apr 2021 16:05:46 +0800 Subject: [PATCH] Run doNotificationSocketConnect for CoinSwapStatus --- ui/redux/actions/app.js | 3 ++- ui/redux/actions/websocket.js | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ui/redux/actions/app.js b/ui/redux/actions/app.js index 2e69506fa..069752f99 100644 --- a/ui/redux/actions/app.js +++ b/ui/redux/actions/app.js @@ -543,8 +543,9 @@ export function doSignIn() { const user = selectUser(state); const notificationsEnabled = SIMPLE_SITE || user.experimental_ui; + dispatch(doNotificationSocketConnect(notificationsEnabled)); + if (notificationsEnabled) { - dispatch(doNotificationSocketConnect()); dispatch(doNotificationList()); } diff --git a/ui/redux/actions/websocket.js b/ui/redux/actions/websocket.js index 5e497fa46..94af728e5 100644 --- a/ui/redux/actions/websocket.js +++ b/ui/redux/actions/websocket.js @@ -59,7 +59,7 @@ export const doSocketDisconnect = (url) => (dispatch) => { } }; -export const doNotificationSocketConnect = () => (dispatch) => { +export const doNotificationSocketConnect = (enableNotifications) => (dispatch) => { const authToken = getAuthToken(); if (!authToken) { console.error('Unable to connect to web socket because auth token is missing'); // eslint-disable-line @@ -69,8 +69,14 @@ export const doNotificationSocketConnect = () => (dispatch) => { const url = `${NOTIFICATION_WS_URL}${authToken}`; doSocketConnect(url, true, (data) => { - if (data.type === 'pending_notification') { - dispatch(doNotificationList()); + switch (data.type) { + case 'pending_notifications': + if (enableNotifications) { + dispatch(doNotificationList()); + } + break; + case 'swap-status': + break; } }); };