diff --git a/src/models/task.js b/src/models/task.js
index 8d65b334..c8a07d19 100644
--- a/src/models/task.js
+++ b/src/models/task.js
@@ -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)
diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue
index 59c12aea..14e22c39 100644
--- a/src/views/tasks/TaskDetailView.vue
+++ b/src/views/tasks/TaskDetailView.vue
@@ -9,8 +9,14 @@
{{ task.identifier }}
Done
-
+
{{ 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