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 }
|
reconnecting: null, // null|Object { attemps, delay, initialDelay }
|
||||||
history: [], // Array of `request`
|
history: [], // Array of `request`
|
||||||
requests: [], // Array of `request`
|
requests: [], // Array of `request`
|
||||||
|
currentRequest: null,
|
||||||
error: null, // null || request
|
error: null, // null || request
|
||||||
historyTimer: null, // null || setTimeout id
|
historyTimer: null, // null || setTimeout id
|
||||||
tempMessages: [], // Array of messages
|
tempMessages: [], // Array of messages
|
||||||
|
@ -43,6 +44,10 @@ export default {
|
||||||
state.reconnecting = args
|
state.reconnecting = args
|
||||||
},
|
},
|
||||||
|
|
||||||
|
SET_CURRENT_REQUEST(state, request) {
|
||||||
|
state.currentRequest = request
|
||||||
|
},
|
||||||
|
|
||||||
ADD_REQUEST(state, request) {
|
ADD_REQUEST(state, request) {
|
||||||
if (state.requests.length > 10) {
|
if (state.requests.length > 10) {
|
||||||
// We do not remove requests right after it resolves since an error might bring
|
// We do not remove requests right after it resolves since an error might bring
|
||||||
|
@ -52,9 +57,9 @@ export default {
|
||||||
state.requests.push(request)
|
state.requests.push(request)
|
||||||
},
|
},
|
||||||
|
|
||||||
UPDATE_REQUEST(state, { request, key, value }) {
|
UPDATE_REQUEST(state, { key, value }) {
|
||||||
// This rely on data persistance and reactivity.
|
// This rely on data persistance and reactivity.
|
||||||
request[key] = value
|
state.currentRequest[key] = value
|
||||||
},
|
},
|
||||||
|
|
||||||
REMOVE_REQUEST(state, request) {
|
REMOVE_REQUEST(state, request) {
|
||||||
|
@ -70,7 +75,7 @@ export default {
|
||||||
state.tempMessages.push([message, type])
|
state.tempMessages.push([message, type])
|
||||||
},
|
},
|
||||||
|
|
||||||
UPDATE_DISPLAYED_MESSAGES(state, { request }) {
|
UPDATE_DISPLAYED_MESSAGES(state) {
|
||||||
if (!state.tempMessages.length) {
|
if (!state.tempMessages.length) {
|
||||||
state.historyTimer = null
|
state.historyTimer = null
|
||||||
return
|
return
|
||||||
|
@ -86,9 +91,10 @@ export default {
|
||||||
)
|
)
|
||||||
state.tempMessages = []
|
state.tempMessages = []
|
||||||
state.historyTimer = null
|
state.historyTimer = null
|
||||||
request.messages = request.messages.concat(messages)
|
state.currentRequest.messages =
|
||||||
request.warnings += warnings
|
state.currentRequest.messages.concat(messages)
|
||||||
request.errors += errors
|
state.currentRequest.warnings += warnings
|
||||||
|
state.currentRequest.errors += errors
|
||||||
},
|
},
|
||||||
|
|
||||||
SET_ERROR(state, request) {
|
SET_ERROR(state, request) {
|
||||||
|
@ -221,6 +227,7 @@ export default {
|
||||||
commit('ADD_HISTORY_ACTION', request)
|
commit('ADD_HISTORY_ACTION', request)
|
||||||
}
|
}
|
||||||
commit('ADD_REQUEST', request)
|
commit('ADD_REQUEST', request)
|
||||||
|
commit('SET_CURRENT_REQUEST', request)
|
||||||
if (wait) {
|
if (wait) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// Display the waiting modal only if the request takes some time.
|
// Display the waiting modal only if the request takes some time.
|
||||||
|
@ -245,13 +252,13 @@ export default {
|
||||||
messages.length &&
|
messages.length &&
|
||||||
messages[messages.length - 1].color === 'warning'
|
messages[messages.length - 1].color === 'warning'
|
||||||
) {
|
) {
|
||||||
request.showWarningMessage = true
|
state.currentRequest.showWarningMessage = true
|
||||||
}
|
}
|
||||||
status = 'warning'
|
status = 'warning'
|
||||||
}
|
}
|
||||||
|
|
||||||
commit('UPDATE_REQUEST', { request, key: 'status', value: status })
|
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.
|
// Remove the overlay after a short delay to allow an error to display withtout flickering.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
commit('SET_WAITING', false)
|
commit('SET_WAITING', false)
|
||||||
|
@ -419,10 +426,7 @@ export default {
|
||||||
reconnecting: (state) => state.reconnecting,
|
reconnecting: (state) => state.reconnecting,
|
||||||
history: (state) => state.history,
|
history: (state) => state.history,
|
||||||
lastAction: (state) => state.history[state.history.length - 1],
|
lastAction: (state) => state.history[state.history.length - 1],
|
||||||
currentRequest: (state) => {
|
currentRequest: (state) => state.currentRequest,
|
||||||
const request = state.requests.find(({ status }) => status === 'pending')
|
|
||||||
return request || state.requests[state.requests.length - 1]
|
|
||||||
},
|
|
||||||
routerKey: (state) => state.routerKey,
|
routerKey: (state) => state.routerKey,
|
||||||
breadcrumb: (state) => state.breadcrumb,
|
breadcrumb: (state) => state.breadcrumb,
|
||||||
transitionName: (state) => state.transitionName,
|
transitionName: (state) => state.transitionName,
|
||||||
|
|
Loading…
Reference in a new issue