Skip to content

Commit

Permalink
Refresh the view when syncing calendar to show syncing status
Browse files Browse the repository at this point in the history
  • Loading branch information
iansan5653 authored Feb 1, 2024
1 parent d63e62f commit 1c926c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/cards/Calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NameFormat, SyncStatus, TeamCalendar } from "../models/TeamCalendar";
import { TeamCalendarId } from "../models/TeamCalendarId";
import { formatGoogleCalendarName, googleCalendarSettingsUrl } from "./utils/googleCalendar";
import { syncStatusText } from "./utils/teamCalendar";
import { QueueFullSyncAllCalendarsAction } from "../endpoints/onQueueFullSyncCalendar";
import { QueueFullSyncCalendarAction } from "../endpoints/onQueueFullSyncCalendar";

function CalendarHeader(calendar: TeamCalendar) {
return CardService.newCardHeader().setTitle(calendar.name);
Expand Down Expand Up @@ -42,7 +42,7 @@ function CalendarStatusSection(calendarId: TeamCalendarId, status: SyncStatus) {
buttons.addButton(
CardService.newTextButton()
.setText("Retry")
.setOnClickAction(QueueFullSyncAllCalendarsAction(calendarId)),
.setOnClickAction(QueueFullSyncCalendarAction(calendarId)),
);
break;

Expand All @@ -61,7 +61,7 @@ function CalendarStatusSection(calendarId: TeamCalendarId, status: SyncStatus) {
buttons.addButton(
CardService.newTextButton()
.setText("Rebuild now")
.setOnClickAction(QueueFullSyncAllCalendarsAction(calendarId)),
.setOnClickAction(QueueFullSyncCalendarAction(calendarId)),
);
break;
}
Expand Down
8 changes: 7 additions & 1 deletion src/endpoints/onQueueFullSyncCalendar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { asyncFullSyncCalendar } from "../jobs/asyncFullSyncCalendar";
import { TeamCalendarId } from "../models/TeamCalendarId";
import { RefreshCalendarViewNavigation } from "./onRefreshCalendarView";
import { Endpoint } from "./utils/Endpoint";
import { TeamCalendarIdParameters } from "./utils/Parameters";

Expand All @@ -8,9 +9,14 @@ export const onQueueFullSyncCalendar: Endpoint = (event) => {
if (!calendarId) throw new Error("Missing parameter: Cannot queue full sync without calendar ID");

asyncFullSyncCalendar(calendarId);

// Refresh the view to update status
return CardService.newActionResponseBuilder()
.setNavigation(RefreshCalendarViewNavigation(calendarId))
.build();
};

export const QueueFullSyncAllCalendarsAction = (calendarId: TeamCalendarId) => {
export const QueueFullSyncCalendarAction = (calendarId: TeamCalendarId) => {
return CardService.newAction()
.setFunctionName(onQueueFullSyncCalendar.name)
.setParameters(new TeamCalendarIdParameters().setId(calendarId).build());
Expand Down

0 comments on commit 1c926c6

Please sign in to comment.