Fix parsing task done at date
continuous-integration/drone/push Build is passing Details

This commit is contained in:
kolaente 2020-12-08 15:43:51 +01:00
parent b885eb7ff2
commit 0b620a07ef
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 23 additions and 8 deletions

View File

@ -3,6 +3,13 @@ import UserModel from './user'
import LabelModel from './label'
import AttachmentModel from './attachment'
const parseDate = date => {
if (date && !date.startsWith('0001')) {
return new Date(date)
}
return null
}
export default class TaskModel extends AbstractModel {
defaultColor = '198CFF'
@ -14,9 +21,10 @@ export default class TaskModel extends AbstractModel {
this.listId = Number(this.listId)
// Make date objects from timestamps
this.dueDate = this.dueDate && !this.dueDate.startsWith('0001') ? new Date(this.dueDate) : null
this.startDate = this.startDate && !this.startDate.startsWith('0001') ? new Date(this.startDate) : null
this.endDate = this.endDate && !this.endDate.startsWith('0001') ? new Date(this.endDate) : null
this.dueDate = parseDate(this.dueDate)
this.startDate = parseDate(this.startDate)
this.endDate = parseDate(this.endDate)
this.doneAt = parseDate(this.doneAt)
// Cancel all scheduled notifications for this task to be sure to only have available notifications
this.cancelScheduledNotifications()
@ -69,7 +77,6 @@ export default class TaskModel extends AbstractModel {
this.created = new Date(this.created)
this.updated = new Date(this.updated)
this.doneAt = this.doneAt ? new Date(this.doneAt) : null
}
defaults() {

View File

@ -5,6 +5,14 @@ import LabelService from './label'
import {formatISO} from 'date-fns'
const parseDate = date => {
if (date) {
return formatISO(new Date(date))
}
return null
}
export default class TaskService extends AbstractService {
constructor() {
super({
@ -34,12 +42,12 @@ export default class TaskService extends AbstractService {
model.listId = Number(model.listId)
// Convert dates into an iso string
model.dueDate = !model.dueDate ? null : formatISO(new Date(model.dueDate))
model.startDate = !model.startDate ? null : formatISO(new Date(model.startDate))
model.endDate = !model.endDate ? null : formatISO(new Date(model.endDate))
model.dueDate = parseDate(model.dueDate)
model.startDate = parseDate(model.startDate)
model.endDate = parseDate(model.endDate)
model.doneAt = parseDate(model.doneAt)
model.created = formatISO(new Date(model.created))
model.updated = formatISO(new Date(model.updated))
model.doneAt = formatISO(new Date(model.doneAt))
// remove all nulls, these would create empty reminders
for (const index in model.reminderDates) {