Fix due date changes not saved on mobile
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2020-10-03 14:30:26 +02:00
parent ff06f808ab
commit 2c6ec6ec35
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 44 additions and 26 deletions

View File

@ -142,6 +142,11 @@ export default class TaskModel extends AbstractModel {
return
}
if (typeof navigator.serviceWorker === 'undefined') {
console.debug('Service Worker not available')
return
}
const registration = await navigator.serviceWorker.getRegistration()
if (typeof registration === 'undefined') {
return
@ -157,6 +162,10 @@ export default class TaskModel extends AbstractModel {
}
async scheduleNotification(date) {
if (typeof navigator.serviceWorker === 'undefined') {
console.debug('Service Worker not available')
return
}
if (date < new Date()) {
console.debug('Date is in the past, not scheduling a notification. Date is ', date)

View File

@ -9,8 +9,14 @@
{{ task.identifier }}
</h1>
<div class="is-done" v-if="task.done">Done</div>
<h1 @focusout="saveTaskOnChange()" @keyup.ctrl.enter="saveTaskOnChange()" class="title input" contenteditable="true"
ref="taskTitle">{{ task.title }}</h1>
<h1
@focusout="saveTaskOnChange()"
@keyup.ctrl.enter="saveTaskOnChange()"
class="title input"
contenteditable="true"
ref="taskTitle">
{{ task.title }}
</h1>
</div>
<h6 class="subtitle" v-if="parent && parent.namespace && parent.list">
{{ parent.namespace.title }} >
@ -552,32 +558,35 @@ export default {
return
}
this.task.dueDate = this.dueDate
this.task.hexColor = this.taskColor
// We're doing the whole update in a nextTick because sometimes race conditions can occur when
// setting the due date on mobile which leads to no due date change being saved.
this.$nextTick(() => {
this.task.dueDate = this.dueDate
this.task.hexColor = this.taskColor
// If no end date is being set, but a start date and due date,
// use the due date as the end date
if (this.task.endDate === null && this.task.startDate !== null && this.task.dueDate !== null) {
this.task.endDate = this.task.dueDate
}
// If no end date is being set, but a start date and due date,
// use the due date as the end date
if (this.task.endDate === null && this.task.startDate !== null && this.task.dueDate !== null) {
this.task.endDate = this.task.dueDate
}
this.$store.dispatch('tasks/update', this.task)
.then(r => {
this.$set(this, 'task', r)
let actions = []
if (undoCallback !== null) {
actions = [{
title: 'Undo',
callback: undoCallback,
}]
this.success({message: 'The task was saved successfully.'}, this, actions)
}
this.dueDate = this.task.dueDate
this.setActiveFields()
})
.catch(e => {
this.error(e, this)
})
this.$store.dispatch('tasks/update', this.task)
.then(r => {
this.$set(this, 'task', r)
let actions = []
if (undoCallback !== null) {
actions = [{
title: 'Undo',
callback: undoCallback,
}]
this.success({message: 'The task was saved successfully.'}, this, actions)
}
this.setActiveFields()
})
.catch(e => {
this.error(e, this)
})
})
},
setFieldActive(fieldName) {
this.activeFields[fieldName] = true