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.
|
* @param {Number} initialDelay - delay before calling the API for the first time in ms.
|
||||||
* @return {Promise<undefined|Error>}
|
* @return {Promise<undefined|Error>}
|
||||||
*/
|
*/
|
||||||
tryToReconnect ({ attemps = 1, delay = 2000, initialDelay = 0 } = {}) {
|
tryToReconnect ({ attemps = 5, delay = 2000, initialDelay = 0 } = {}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const api = this
|
const api = this
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ export default {
|
||||||
connected: localStorage.getItem('connected') === 'true', // Boolean
|
connected: localStorage.getItem('connected') === 'true', // Boolean
|
||||||
yunohost: null, // Object { version, repo }
|
yunohost: null, // Object { version, repo }
|
||||||
waiting: false, // Boolean
|
waiting: false, // Boolean
|
||||||
reconnecting: false, // Boolean
|
reconnecting: null, // null|Object { attemps, delay, initialDelay }
|
||||||
history: [], // Array of `request`
|
history: [], // Array of `request`
|
||||||
requests: [], // Array of `request`
|
requests: [], // Array of `request`
|
||||||
error: null, // null || request
|
error: null, // null || request
|
||||||
|
@ -32,8 +32,8 @@ export default {
|
||||||
state.waiting = boolean
|
state.waiting = boolean
|
||||||
},
|
},
|
||||||
|
|
||||||
'SET_RECONNECTING' (state, boolean) {
|
'SET_RECONNECTING' (state, args) {
|
||||||
state.reconnecting = boolean
|
state.reconnecting = args
|
||||||
},
|
},
|
||||||
|
|
||||||
'ADD_REQUEST' (state, request) {
|
'ADD_REQUEST' (state, request) {
|
||||||
|
@ -138,8 +138,9 @@ export default {
|
||||||
return api.get('logout')
|
return api.get('logout')
|
||||||
},
|
},
|
||||||
|
|
||||||
'TRY_TO_RECONNECT' ({ commit, dispatch }) {
|
'TRY_TO_RECONNECT' ({ commit, dispatch }, args = {}) {
|
||||||
commit('SET_RECONNECTING', true)
|
// 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')
|
dispatch('RESET_CONNECTED')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -56,13 +56,13 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['currentRequest'])
|
...mapGetters(['reconnecting'])
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
tryToReconnect ({ initialDelay = 0 } = {}) {
|
tryToReconnect (initialDelay = 0) {
|
||||||
this.status = 'reconnecting'
|
this.status = 'reconnecting'
|
||||||
api.tryToReconnect({ initialDelay }).then(() => {
|
api.tryToReconnect({ ...this.reconnecting, initialDelay }).then(() => {
|
||||||
this.status = 'success'
|
this.status = 'success'
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.status = 'failed'
|
this.status = 'failed'
|
||||||
|
@ -71,9 +71,8 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
created () {
|
created () {
|
||||||
const origin = this.currentRequest.humanRouteKey
|
this.origin = this.reconnecting.origin || 'unknown'
|
||||||
this.origin = ['upgrade.system'].includes(origin) ? origin.replace('.', '_') : 'unknown'
|
this.tryToReconnect(this.reconnecting.initialDelay)
|
||||||
this.tryToReconnect({ initialDelay: 2000 })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue