Skip to content

Commit 740b54c

Browse files
committed
be more transparent about caching behavior to editors
1 parent 465ffee commit 740b54c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/api/routes/events.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
QueryCommand,
1111
ScanCommand,
1212
} from "@aws-sdk/client-dynamodb";
13-
import { genericConfig } from "../../common/config.js";
13+
import { EVENT_CACHED_DURATION, genericConfig } from "../../common/config.js";
1414
import { marshall, unmarshall } from "@aws-sdk/util-dynamodb";
1515
import {
1616
BaseError,
@@ -26,8 +26,7 @@ import { IUpdateDiscord, updateDiscord } from "../functions/discord.js";
2626
import rateLimiter from "api/plugins/rateLimiter.js";
2727

2828
const repeatOptions = ["weekly", "biweekly"] as const;
29-
const CLIENT_HTTP_CACHE_POLICY =
30-
"public, max-age=120, stale-while-revalidate=420, stale-if-error=3600";
29+
const CLIENT_HTTP_CACHE_POLICY = `public, max-age=${EVENT_CACHED_DURATION}, stale-while-revalidate=420, stale-if-error=3600`;
3130
export type EventRepeatOptions = (typeof repeatOptions)[number];
3231

3332
const baseSchema = z.object({

src/common/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,6 @@ const roleArns = {
126126
Entra: process.env.EntraRoleArn,
127127
};
128128

129+
export const EVENT_CACHED_DURATION = 120;
130+
129131
export { genericConfig, environmentConfig, roleArns };

src/ui/pages/events/ManageEvent.page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getRunEnvironmentConfig } from '@ui/config';
1111
import { useApi } from '@ui/util/api';
1212
import { OrganizationList as orgList } from '@common/orgs';
1313
import { AppRoles } from '@common/roles';
14+
import { EVENT_CACHED_DURATION } from '@common/config';
1415

1516
export function capitalizeFirstLetter(string: string) {
1617
return string.charAt(0).toUpperCase() + string.slice(1);
@@ -138,10 +139,10 @@ export const ManageEventPage: React.FC = () => {
138139
};
139140

140141
const eventURL = isEditing ? `/api/v1/events/${eventId}` : '/api/v1/events';
141-
const response = await api.post(eventURL, realValues);
142+
await api.post(eventURL, realValues);
142143
notifications.show({
143144
title: isEditing ? 'Event updated!' : 'Event created!',
144-
message: isEditing ? undefined : `The event ID is "${response.data.id}".`,
145+
message: `Changes may take up to ${Math.ceil(EVENT_CACHED_DURATION / 60)} minutes to reflect to users.`,
145146
});
146147
navigate('/events/manage');
147148
} catch (error) {

0 commit comments

Comments
 (0)