mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
fix: temp fix for reactivity problems on nested obj request
This commit is contained in:
parent
796dad8dbe
commit
23594bc338
1 changed files with 16 additions and 12 deletions
|
@ -13,6 +13,7 @@ export default {
|
|||
reconnecting: null, // null|Object { attemps, delay, initialDelay }
|
||||
history: [], // Array of `request`
|
||||
requests: [], // Array of `request`
|
||||
currentRequest: null,
|
||||
error: null, // null || request
|
||||
historyTimer: null, // null || setTimeout id
|
||||
tempMessages: [], // Array of messages
|
||||
|
@ -43,6 +44,10 @@ export default {
|
|||
state.reconnecting = args
|
||||
},
|
||||
|
||||
SET_CURRENT_REQUEST(state, request) {
|
||||
state.currentRequest = request
|
||||
},
|
||||
|
||||
ADD_REQUEST(state, request) {
|
||||
if (state.requests.length > 10) {
|
||||
// We do not remove requests right after it resolves since an error might bring
|
||||
|
@ -52,9 +57,9 @@ export default {
|
|||
state.requests.push(request)
|
||||
},
|
||||
|
||||
UPDATE_REQUEST(state, { request, key, value }) {
|
||||
UPDATE_REQUEST(state, { key, value }) {
|
||||
// This rely on data persistance and reactivity.
|
||||
request[key] = value
|
||||
state.currentRequest[key] = value
|
||||
},
|
||||
|
||||
REMOVE_REQUEST(state, request) {
|
||||
|
@ -70,7 +75,7 @@ export default {
|
|||
state.tempMessages.push([message, type])
|
||||
},
|
||||
|
||||
UPDATE_DISPLAYED_MESSAGES(state, { request }) {
|
||||
UPDATE_DISPLAYED_MESSAGES(state) {
|
||||
if (!state.tempMessages.length) {
|
||||
state.historyTimer = null
|
||||
return
|
||||
|
@ -86,9 +91,10 @@ export default {
|
|||
)
|
||||
state.tempMessages = []
|
||||
state.historyTimer = null
|
||||
request.messages = request.messages.concat(messages)
|
||||
request.warnings += warnings
|
||||
request.errors += errors
|
||||
state.currentRequest.messages =
|
||||
state.currentRequest.messages.concat(messages)
|
||||
state.currentRequest.warnings += warnings
|
||||
state.currentRequest.errors += errors
|
||||
},
|
||||
|
||||
SET_ERROR(state, request) {
|
||||
|
@ -221,6 +227,7 @@ export default {
|
|||
commit('ADD_HISTORY_ACTION', request)
|
||||
}
|
||||
commit('ADD_REQUEST', request)
|
||||
commit('SET_CURRENT_REQUEST', request)
|
||||
if (wait) {
|
||||
setTimeout(() => {
|
||||
// Display the waiting modal only if the request takes some time.
|
||||
|
@ -245,13 +252,13 @@ export default {
|
|||
messages.length &&
|
||||
messages[messages.length - 1].color === 'warning'
|
||||
) {
|
||||
request.showWarningMessage = true
|
||||
state.currentRequest.showWarningMessage = true
|
||||
}
|
||||
status = 'warning'
|
||||
}
|
||||
|
||||
commit('UPDATE_REQUEST', { request, key: 'status', value: status })
|
||||
if (wait && !request.showWarningMessage) {
|
||||
if (wait && !state.currentRequest.showWarningMessage) {
|
||||
// Remove the overlay after a short delay to allow an error to display withtout flickering.
|
||||
setTimeout(() => {
|
||||
commit('SET_WAITING', false)
|
||||
|
@ -419,10 +426,7 @@ export default {
|
|||
reconnecting: (state) => state.reconnecting,
|
||||
history: (state) => state.history,
|
||||
lastAction: (state) => state.history[state.history.length - 1],
|
||||
currentRequest: (state) => {
|
||||
const request = state.requests.find(({ status }) => status === 'pending')
|
||||
return request || state.requests[state.requests.length - 1]
|
||||
},
|
||||
currentRequest: (state) => state.currentRequest,
|
||||
routerKey: (state) => state.routerKey,
|
||||
breadcrumb: (state) => state.breadcrumb,
|
||||
transitionName: (state) => state.transitionName,
|
||||
|
|
Loading…
Reference in a new issue