From 4cb2946ea9eee00a2773ee8e5e9b271f52163360 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Tue, 25 Nov 2025 01:11:13 +1100 Subject: [PATCH] Group calendar cringe toggle --- src/api/group.js | 24 ++- src/localization/en.json | 3 +- src/service/request.js | 14 +- src/types/api/group.d.ts | 12 +- .../components/GroupCalendarEventCard.vue | 7 +- .../Tools/dialogs/GroupCalendarDialog.vue | 164 ++++++++++++++---- 6 files changed, 175 insertions(+), 49 deletions(-) diff --git a/src/api/group.js b/src/api/group.js index 589fa233..6e99e8e2 100644 --- a/src/api/group.js +++ b/src/api/group.js @@ -735,24 +735,30 @@ const groupReq = { /** * @type {import('../types/api/group').GetCalendars} */ - getGroupCalendars(date) { - return request(`calendar?date=${date}`, { - method: 'GET' + getGroupCalendars(params) { + return request('calendar', { + method: 'GET', + params }); }, /** * @type {import('../types/api/group').GetFollowingCalendars} */ - getFollowingGroupCalendars(date) { - return request(`calendar/following?date=${date}`, { - method: 'GET' + getFollowingGroupCalendars(params) { + return request('calendar/following', { + method: 'GET', + params }); }, - getFeaturedGroupCalendars(date) { - return request(`calendar/featured?date=${date}`, { - method: 'GET' + /** + * @type {import('../types/api/group').GetFeaturedCalendars} + */ + getFeaturedGroupCalendars(params) { + return request('calendar/featured', { + method: 'GET', + params }); }, diff --git a/src/localization/en.json b/src/localization/en.json index f3bc93e4..4f55864b 100644 --- a/src/localization/en.json +++ b/src/localization/en.json @@ -1814,7 +1814,8 @@ "description": "Description", "export_to_calendar": "Export to Calendar", "download_ics": "Download .ics" - } + }, + "featured_events": "Featured Events" }, "moderate_group": { "header": "Moderate Group Member", diff --git a/src/service/request.js b/src/service/request.js index 2c747cad..9dd819d0 100644 --- a/src/service/request.js +++ b/src/service/request.js @@ -371,7 +371,16 @@ export async function processBulk(options) { try { while (true) { const result = await fn(params); - const batchSize = result.json.length; + let batchSize = 0; + if (Array.isArray(result.json)) { + batchSize = result.json.length; + } else if (Array.isArray(result.results)) { + batchSize = result.results.length; + } else { + throw new Error( + 'Invalid result format: expected an array in result.json or result.results' + ); + } if (typeof handle === 'function') { handle(result); @@ -379,6 +388,9 @@ export async function processBulk(options) { if (batchSize === 0) { break; } + if (typeof result.hasNext === 'boolean' && !result.hasNext) { + break; + } if (N > 0) { totalFetched += batchSize; diff --git a/src/types/api/group.d.ts b/src/types/api/group.d.ts index bc3c04cb..b93ef0fc 100644 --- a/src/types/api/group.d.ts +++ b/src/types/api/group.d.ts @@ -7,9 +7,17 @@ export type GetGroup = (params: { params: { groupId: string; includeRoles?: boolean }; }>; -export type GetCalendars = (date: string) => Promise; +export type GetCalendars = (params: { + date: string; +}) => Promise; -export type GetFollowingCalendars = (date: string) => Promise; +export type GetFollowingCalendars = (params: { + date: string; +}) => Promise; + +export type GetFeaturedCalendars = (params: { + date: string; +}) => Promise; // API response types interface GetGroupResponse { diff --git a/src/views/Tools/components/GroupCalendarEventCard.vue b/src/views/Tools/components/GroupCalendarEventCard.vue index e5ffa690..d6a4a39b 100644 --- a/src/views/Tools/components/GroupCalendarEventCard.vue +++ b/src/views/Tools/components/GroupCalendarEventCard.vue @@ -1,6 +1,6 @@
@@ -120,20 +124,21 @@