forked from AkkomaGang/akkoma-fe
added notices for ws events
This commit is contained in:
parent
adc3b17fe0
commit
64fa662644
3 changed files with 28 additions and 1 deletions
|
@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Follows/Followers tabs on user profiles now display the content properly.
|
- Follows/Followers tabs on user profiles now display the content properly.
|
||||||
- Handle punycode in screen names
|
- Handle punycode in screen names
|
||||||
- Fixed local dev mode having non-functional websockets in some cases
|
- Fixed local dev mode having non-functional websockets in some cases
|
||||||
|
- Show notices for websocket events (errors, abnormal closures, reconnections)
|
||||||
|
|
||||||
## [2.2.2] - 2020-12-22
|
## [2.2.2] - 2020-12-22
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -646,7 +646,10 @@
|
||||||
"reload": "Reload",
|
"reload": "Reload",
|
||||||
"up_to_date": "Up-to-date",
|
"up_to_date": "Up-to-date",
|
||||||
"no_more_statuses": "No more statuses",
|
"no_more_statuses": "No more statuses",
|
||||||
"no_statuses": "No statuses"
|
"no_statuses": "No statuses",
|
||||||
|
"socket_reconnected": "Realtime connection established",
|
||||||
|
"socket_broke": "Realtime connection lost: CloseEvent code {0}",
|
||||||
|
"socket_closed": "No realtime connection, updates can arrive with a delaye until connection is re-established"
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
"favorites": "Favorites",
|
"favorites": "Favorites",
|
||||||
|
|
|
@ -91,12 +91,29 @@ const api = {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
state.mastoUserSocket.addEventListener('open', () => {
|
state.mastoUserSocket.addEventListener('open', () => {
|
||||||
|
// Do not show notification when we just opened up the page
|
||||||
|
if (state.mastoUserSocketStatus !== null) {
|
||||||
|
dispatch('pushGlobalNotice', {
|
||||||
|
level: 'success',
|
||||||
|
messageKey: 'timeline.socket_reconnected',
|
||||||
|
timeout: 5000
|
||||||
|
})
|
||||||
|
}
|
||||||
commit('setMastoUserSocketStatus', WSConnectionStatus.JOINED)
|
commit('setMastoUserSocketStatus', WSConnectionStatus.JOINED)
|
||||||
})
|
})
|
||||||
state.mastoUserSocket.addEventListener('error', ({ detail: error }) => {
|
state.mastoUserSocket.addEventListener('error', ({ detail: error }) => {
|
||||||
console.error('Error in MastoAPI websocket:', error)
|
console.error('Error in MastoAPI websocket:', error)
|
||||||
commit('setMastoUserSocketStatus', WSConnectionStatus.ERROR)
|
commit('setMastoUserSocketStatus', WSConnectionStatus.ERROR)
|
||||||
dispatch('clearOpenedChats')
|
dispatch('clearOpenedChats')
|
||||||
|
/* Since data in WS event for error is useless it's better to show
|
||||||
|
* generic warning instead of in "close" which actually has some
|
||||||
|
* useful data
|
||||||
|
*/
|
||||||
|
dispatch('pushGlobalNotice', {
|
||||||
|
level: 'error',
|
||||||
|
messageKey: 'timeline.socket_closed',
|
||||||
|
timeout: 5000
|
||||||
|
})
|
||||||
})
|
})
|
||||||
state.mastoUserSocket.addEventListener('close', ({ detail: closeEvent }) => {
|
state.mastoUserSocket.addEventListener('close', ({ detail: closeEvent }) => {
|
||||||
const ignoreCodes = new Set([
|
const ignoreCodes = new Set([
|
||||||
|
@ -112,6 +129,12 @@ const api = {
|
||||||
dispatch('startFetchingNotifications')
|
dispatch('startFetchingNotifications')
|
||||||
dispatch('startFetchingChats')
|
dispatch('startFetchingChats')
|
||||||
dispatch('restartMastoUserSocket')
|
dispatch('restartMastoUserSocket')
|
||||||
|
dispatch('pushGlobalNotice', {
|
||||||
|
level: 'error',
|
||||||
|
messageKey: 'timeline.socket_broke',
|
||||||
|
messageArgs: [code],
|
||||||
|
timeout: 5000
|
||||||
|
})
|
||||||
}
|
}
|
||||||
commit('setMastoUserSocketStatus', WSConnectionStatus.CLOSED)
|
commit('setMastoUserSocketStatus', WSConnectionStatus.CLOSED)
|
||||||
dispatch('clearOpenedChats')
|
dispatch('clearOpenedChats')
|
||||||
|
|
Loading…
Reference in a new issue