Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feature) Notify users sync is being paused until connection is resumed #537

Merged
merged 5 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,9 @@
},
"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",
"netResumed": "Internet connection restored fetching data resumed"
},
"subaccounts": {
"add_account": "Add Account",
Expand Down
2 changes: 2 additions & 0 deletions src/state/ws/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
WS_CONNECT: 'ws_connect',
WS_RECONNECT: 'ws_reconnect',
WS_NET_ERROR: 'ws_emitENetError',
WS_NET_RESUMED: 'ws_emitENetResumed',
}
11 changes: 11 additions & 0 deletions src/state/ws/saga.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { call, put, takeLatest } from 'redux-saga/effects'

import { updateSyncStatus } from 'state/sync/actions'
import { updateStatus, updateWarningStatus } from 'state/status/actions'

import types from './constants'
import login from './signIn'
Expand All @@ -13,6 +14,16 @@ function* reconnect() {
}
}

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)
}