From e6d5ea6a2d042b912e20024dda63751bc4d9ecde Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Fri, 5 Aug 2022 15:25:31 +0300 Subject: [PATCH 1/5] Add net status related ws constants --- src/state/ws/constants.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/state/ws/constants.js b/src/state/ws/constants.js index 2077ecd91..f30611855 100644 --- a/src/state/ws/constants.js +++ b/src/state/ws/constants.js @@ -1,4 +1,6 @@ export default { WS_CONNECT: 'ws_connect', WS_RECONNECT: 'ws_reconnect', + WS_NET_ERROR: 'ws_emitENetError', + WS_NET_RESUMED: 'ws_emitENetResumed', } From 431502f7affa2296fd87c5dacabd03d1c9921762 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 8 Aug 2022 14:45:50 +0300 Subject: [PATCH 2/5] Add net error key/description --- public/locales/en/translations.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index 4be49d7ba..ab3c743b9 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -432,7 +432,8 @@ }, "signInFail": "Invalid credentials", "timeframe_update": "Time frame updated", - "signUpFail": "Invalid API Key or Secret" + "signUpFail": "Invalid API Key or Secret", + "netError": "Fetching data paused due broken internet connection" }, "subaccounts": { "add_account": "Add Account", From af7d7f677935f3ba11bcc37ef4c663f6219bbabe Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Mon, 8 Aug 2022 15:59:28 +0300 Subject: [PATCH 3/5] Add notify net errors saga --- src/state/ws/saga.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/state/ws/saga.js b/src/state/ws/saga.js index 6891a5de6..370983521 100644 --- a/src/state/ws/saga.js +++ b/src/state/ws/saga.js @@ -1,6 +1,7 @@ import { call, put, takeLatest } from 'redux-saga/effects' import { updateSyncStatus } from 'state/sync/actions' +import { updateWarningStatus } from 'state/status/actions' import types from './constants' import login from './signIn' @@ -13,6 +14,11 @@ function* reconnect() { } } +function* notifyNetError() { + yield put(updateWarningStatus({ id: 'status.netError' })) +} + export default function* wsSaga() { yield takeLatest(types.WS_RECONNECT, reconnect) + yield takeLatest(types.WS_NET_ERROR, notifyNetError) } From 1235680be18cd3a66a68e20b3bce0b65a3b3bf94 Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 9 Aug 2022 13:15:29 +0300 Subject: [PATCH 4/5] Update locales --- public/locales/en/translations.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index ab3c743b9..fc9f00a1f 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -433,7 +433,8 @@ "signInFail": "Invalid credentials", "timeframe_update": "Time frame updated", "signUpFail": "Invalid API Key or Secret", - "netError": "Fetching data paused due broken internet connection" + "netError": "Fetching data paused due broken internet connection", + "netResumed": "Internet connection restored fetching data resumed" }, "subaccounts": { "add_account": "Add Account", From 78e4da9896115e8378810b23361e4a1339fa2fae Mon Sep 17 00:00:00 2001 From: alexstotsky Date: Tue, 9 Aug 2022 13:47:30 +0300 Subject: [PATCH 5/5] Implement net resumed notification --- src/state/ws/saga.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/state/ws/saga.js b/src/state/ws/saga.js index 370983521..a6abcd2ff 100644 --- a/src/state/ws/saga.js +++ b/src/state/ws/saga.js @@ -1,7 +1,7 @@ import { call, put, takeLatest } from 'redux-saga/effects' import { updateSyncStatus } from 'state/sync/actions' -import { updateWarningStatus } from 'state/status/actions' +import { updateStatus, updateWarningStatus } from 'state/status/actions' import types from './constants' import login from './signIn' @@ -18,7 +18,12 @@ function* notifyNetError() { yield put(updateWarningStatus({ id: 'status.netError' })) } +function* notifyNetResumed() { + yield put(updateStatus({ id: 'status.netResumed' })) +} + export default function* wsSaga() { yield takeLatest(types.WS_RECONNECT, reconnect) yield takeLatest(types.WS_NET_ERROR, notifyNetError) + yield takeLatest(types.WS_NET_RESUMED, notifyNetResumed) }