From 730683fe2542318135c4fb2ce4c78f2f7b81ba41 Mon Sep 17 00:00:00 2001 From: Kendall Garner <17521368+kgarner7@users.noreply.github.com> Date: Mon, 16 Sep 2024 17:33:06 -0700 Subject: [PATCH 1/2] different date formats based off of metadata --- src/renderer/utils/format.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/renderer/utils/format.tsx b/src/renderer/utils/format.tsx index 0f2ce226..3e983b47 100644 --- a/src/renderer/utils/format.tsx +++ b/src/renderer/utils/format.tsx @@ -8,13 +8,22 @@ import { Rating } from '/@/renderer/components/rating'; dayjs.extend(relativeTime); dayjs.extend(utc); -const DATE_FORMAT = 'MMM D, YYYY'; +const FORMATS: Record = Object.freeze({ + 0: 'YYYY', + 1: 'MMM YYYY', + 2: 'MMM D, YYYY', +}); + +const getDateFormat = (key: string): string => { + const dashes = Math.min(key.split('-').length - 1, 2); + return FORMATS[dashes]; +}; export const formatDateAbsolute = (key: string | null) => - key ? dayjs(key).format(DATE_FORMAT) : ''; + key ? dayjs(key).format(getDateFormat(key)) : ''; export const formatDateAbsoluteUTC = (key: string | null) => - key ? dayjs.utc(key).format(DATE_FORMAT) : ''; + key ? dayjs.utc(key).format(getDateFormat(key)) : ''; export const formatDateRelative = (key: string | null) => (key ? dayjs(key).fromNow() : ''); From 4c49e403abe1b0ecf8a5f327e6166eae997f138f Mon Sep 17 00:00:00 2001 From: Kendall Garner <17521368+kgarner7@users.noreply.github.com> Date: Mon, 16 Sep 2024 19:57:59 -0700 Subject: [PATCH 2/2] make headers optional? --- src/renderer/api/subsonic/subsonic-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/api/subsonic/subsonic-api.ts b/src/renderer/api/subsonic/subsonic-api.ts index 7e36d8cb..bb0dc3c1 100644 --- a/src/renderer/api/subsonic/subsonic-api.ts +++ b/src/renderer/api/subsonic/subsonic-api.ts @@ -242,7 +242,7 @@ export const ssApiClient = (args: { return { body: response?.data, - headers: response.headers as any, + headers: response?.headers as any, status: response?.status, }; }