]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: due date nullable
authorChristopher Ng <chrng8@gmail.com>
Thu, 3 Aug 2023 02:15:00 +0000 (19:15 -0700)
committerAndy Scherzinger <info@andy-scherzinger.de>
Thu, 10 Aug 2023 10:28:19 +0000 (12:28 +0200)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
(cherry picked from commit efed517976e3bcf8d27255a965585f5997913373)

apps/files_reminders/src/services/reminderService.ts

index ed22307b6779afedb5120574472085cca5aeabcd..bcfa09e2b78eacc8734b57711d2fec6781a192a9 100644 (file)
@@ -24,15 +24,16 @@ import axios from '@nextcloud/axios'
 import { generateOcsUrl } from '@nextcloud/router'
 
 interface Reminder {
-       dueDate: Date
+       dueDate: null | Date
 }
 
 export const getReminder = async (fileId: number): Promise<Reminder> => {
        const url = generateOcsUrl('/apps/files_reminders/api/v1/get/{fileId}', { fileId })
        const response = await axios.get(url)
+       const dueDate = response.data.dueDate ? new Date(response.data.dueDate) : null
 
        return {
-               dueDate: new Date(response.data.ocs.data.dueDate),
+               dueDate,
        }
 }
 
@@ -40,15 +41,15 @@ export const setReminder = async (fileId: number, dueDate: Date): Promise<[]> =>
        const url = generateOcsUrl('/apps/files_reminders/api/v1/set/{fileId}', { fileId })
 
        const response = await axios.put(url, {
-               dueDate: dueDate.toISOString(),
+               dueDate: dueDate.toISOString(), // timezone of string is always UTC
        })
 
-       return response.data.ocs.data
+       return response.data
 }
 
 export const clearReminder = async (fileId: number): Promise<[]> => {
        const url = generateOcsUrl('/apps/files_reminders/api/v1/remove/{fileId}', { fileId })
        const response = await axios.delete(url)
 
-       return response.data.ocs.data
+       return response.data
 }