Completed recurrence work (#16)
Requests can now: - be entered with recurrence - be updated with recurrence - manually skip recurrence period Also did an app-wide clean-up to ensure that everything is done the same way in all places
This commit is contained in:
@@ -7,6 +7,8 @@ export default {
|
||||
LOAD_JOURNAL: 'load-journal',
|
||||
/** Action to update a request */
|
||||
UPDATE_REQUEST: 'update-request',
|
||||
/** Action to skip the remaining recurrence period */
|
||||
SHOW_REQUEST_NOW: 'show-request-now',
|
||||
/** Action to snooze a request */
|
||||
SNOOZE_REQUEST: 'snooze-request'
|
||||
}
|
||||
|
||||
@@ -73,10 +73,10 @@ export default new Vuex.Store({
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async [actions.ADD_REQUEST] ({ commit }, { progress, requestText }) {
|
||||
async [actions.ADD_REQUEST] ({ commit }, { progress, requestText, recurType, recurCount }) {
|
||||
progress.start()
|
||||
try {
|
||||
const newRequest = await api.addRequest(requestText)
|
||||
const newRequest = await api.addRequest(requestText, recurType, recurCount)
|
||||
commit(mutations.REQUEST_ADDED, newRequest.data)
|
||||
progress.finish()
|
||||
} catch (err) {
|
||||
@@ -100,10 +100,28 @@ export default new Vuex.Store({
|
||||
commit(mutations.LOADING_JOURNAL, false)
|
||||
}
|
||||
},
|
||||
async [actions.UPDATE_REQUEST] ({ commit }, { progress, requestId, status, updateText }) {
|
||||
async [actions.UPDATE_REQUEST] ({ commit, state }, { progress, requestId, status, updateText, recurType, recurCount }) {
|
||||
progress.start()
|
||||
try {
|
||||
await api.updateRequest({ requestId, status, updateText })
|
||||
let oldReq = (state.journal.filter(req => req.requestId === requestId) || [])[0] || {}
|
||||
if (status !== 'Updated' || oldReq.text !== updateText) {
|
||||
await api.updateRequest(requestId, status, updateText)
|
||||
}
|
||||
if (status === 'Updated' && (oldReq.recurType !== recurType || oldReq.recurCount !== recurCount)) {
|
||||
await api.updateRecurrence(requestId, recurType, recurCount)
|
||||
}
|
||||
const request = await api.getRequest(requestId)
|
||||
commit(mutations.REQUEST_UPDATED, request.data)
|
||||
progress.finish()
|
||||
} catch (err) {
|
||||
logError(err)
|
||||
progress.fail()
|
||||
}
|
||||
},
|
||||
async [actions.SHOW_REQUEST_NOW] ({ commit }, { progress, requestId, showAfter }) {
|
||||
progress.start()
|
||||
try {
|
||||
await api.showRequest(requestId, showAfter)
|
||||
const request = await api.getRequest(requestId)
|
||||
commit(mutations.REQUEST_UPDATED, request.data)
|
||||
progress.finish()
|
||||
|
||||
Reference in New Issue
Block a user