mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
update reconnecting as args to be passed to ReconnectingDisplay
This commit is contained in:
parent
335d38bd5d
commit
f5853f2040
3 changed files with 12 additions and 12 deletions
|
@ -199,7 +199,7 @@ export default {
|
|||
* @param {Number} initialDelay - delay before calling the API for the first time in ms.
|
||||
* @return {Promise<undefined|Error>}
|
||||
*/
|
||||
tryToReconnect ({ attemps = 1, delay = 2000, initialDelay = 0 } = {}) {
|
||||
tryToReconnect ({ attemps = 5, delay = 2000, initialDelay = 0 } = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const api = this
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ export default {
|
|||
connected: localStorage.getItem('connected') === 'true', // Boolean
|
||||
yunohost: null, // Object { version, repo }
|
||||
waiting: false, // Boolean
|
||||
reconnecting: false, // Boolean
|
||||
reconnecting: null, // null|Object { attemps, delay, initialDelay }
|
||||
history: [], // Array of `request`
|
||||
requests: [], // Array of `request`
|
||||
error: null, // null || request
|
||||
|
@ -32,8 +32,8 @@ export default {
|
|||
state.waiting = boolean
|
||||
},
|
||||
|
||||
'SET_RECONNECTING' (state, boolean) {
|
||||
state.reconnecting = boolean
|
||||
'SET_RECONNECTING' (state, args) {
|
||||
state.reconnecting = args
|
||||
},
|
||||
|
||||
'ADD_REQUEST' (state, request) {
|
||||
|
@ -138,8 +138,9 @@ export default {
|
|||
return api.get('logout')
|
||||
},
|
||||
|
||||
'TRY_TO_RECONNECT' ({ commit, dispatch }) {
|
||||
commit('SET_RECONNECTING', true)
|
||||
'TRY_TO_RECONNECT' ({ commit, dispatch }, args = {}) {
|
||||
// FIXME This is very ugly arguments forwarding, will use proper component way of doing this when switching to Vue 3 (teleport)
|
||||
commit('SET_RECONNECTING', args)
|
||||
dispatch('RESET_CONNECTED')
|
||||
},
|
||||
|
||||
|
|
|
@ -56,13 +56,13 @@ export default {
|
|||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters(['currentRequest'])
|
||||
...mapGetters(['reconnecting'])
|
||||
},
|
||||
|
||||
methods: {
|
||||
tryToReconnect ({ initialDelay = 0 } = {}) {
|
||||
tryToReconnect (initialDelay = 0) {
|
||||
this.status = 'reconnecting'
|
||||
api.tryToReconnect({ initialDelay }).then(() => {
|
||||
api.tryToReconnect({ ...this.reconnecting, initialDelay }).then(() => {
|
||||
this.status = 'success'
|
||||
}).catch(() => {
|
||||
this.status = 'failed'
|
||||
|
@ -71,9 +71,8 @@ export default {
|
|||
},
|
||||
|
||||
created () {
|
||||
const origin = this.currentRequest.humanRouteKey
|
||||
this.origin = ['upgrade.system'].includes(origin) ? origin.replace('.', '_') : 'unknown'
|
||||
this.tryToReconnect({ initialDelay: 2000 })
|
||||
this.origin = this.reconnecting.origin || 'unknown'
|
||||
this.tryToReconnect(this.reconnecting.initialDelay)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue