Skip to content

Commit

Permalink
UI: Fix caching (#1058)
Browse files Browse the repository at this point in the history
Refreshing in the slot page was not updating the slot table data since
we aren't disabling caching there like we are in the mirrors edit page.
Same goes for mirror errors page. Also just adds `cache:no-store` in a
few other fetches for safety
  • Loading branch information
Amogh-Bharadwaj authored Jan 11, 2024
1 parent 7cdfb86 commit be09741
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ui/app/mirrors/create/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export const fetchSchemas = async (peerName: string) => {
body: JSON.stringify({
peerName,
}),
cache: 'no-store',
}).then((res) => res.json());
return schemasRes.schemas;
};
Expand All @@ -278,6 +279,7 @@ export const fetchTables = async (
peerName,
schemaName,
}),
cache: 'no-store',
}).then((res) => res.json());

let tables: TableMapRow[] = [];
Expand Down Expand Up @@ -320,6 +322,7 @@ export const fetchColumns = async (
schemaName,
tableName,
}),
cache: 'no-store',
}).then((res) => res.json());
setLoading(false);
return columnsRes.columns;
Expand All @@ -332,6 +335,7 @@ export const fetchAllTables = async (peerName: string) => {
body: JSON.stringify({
peerName,
}),
cache: 'no-store',
}).then((res) => res.json());
return tablesRes.tables;
};
2 changes: 1 addition & 1 deletion ui/app/mirrors/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function CreateMirrors() {
BETWEEN {{.start}} AND {{.end}}`);

useEffect(() => {
fetch('/api/peers')
fetch('/api/peers', { cache: 'no-store' })
.then((res) => res.json())
.then((res) => {
setPeers(res);
Expand Down
1 change: 1 addition & 0 deletions ui/app/mirrors/errors/[mirrorName]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default function MirrorError() {
headers: {
'Content-Type': 'application/json',
},
cache: 'no-store',
body: JSON.stringify(req),
});
const data: MirrorLogsResponse = await response.json();
Expand Down
8 changes: 6 additions & 2 deletions ui/app/peers/[peerName]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const PeerData = async ({ params: { peerName } }: DataConfigProps) => {
const flowServiceAddr = GetFlowHttpAddressFromEnv();

const peerSlots: PeerSlotResponse = await fetch(
`${flowServiceAddr}/v1/peers/slots/${peerName}`
`${flowServiceAddr}/v1/peers/slots/${peerName}`,
{
cache: 'no-store',
}
).then((res) => res.json());

const slotArray = peerSlots.slotData;
Expand All @@ -42,7 +45,8 @@ const PeerData = async ({ params: { peerName } }: DataConfigProps) => {
const flowServiceAddr = GetFlowHttpAddressFromEnv();

const peerStats: PeerStatResponse = await fetch(
`${flowServiceAddr}/v1/peers/stats/${peerName}`
`${flowServiceAddr}/v1/peers/stats/${peerName}`,
{ cache: 'no-store' }
).then((res) => res.json());

return peerStats.statData;
Expand Down
2 changes: 2 additions & 0 deletions ui/app/peers/create/[peerType]/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const handleValidate = async (
config,
mode: 'validate',
}),
cache: 'no-store',
}).then((res) => res.json());
if (!valid.valid) {
setMessage({ ok: false, msg: valid.message });
Expand Down Expand Up @@ -118,6 +119,7 @@ export const handleCreate = async (
config,
mode: 'create',
}),
cache: 'no-store',
}).then((res) => res.json());
if (!createdPeer.created) {
setMessage({ ok: false, msg: createdPeer.message });
Expand Down

0 comments on commit be09741

Please sign in to comment.