Add ability to reload hero status

This commit is contained in:
Lim Chee Aun 2023-03-14 00:36:40 +08:00
parent a3ea2cb752
commit f4310ad8e4

View file

@ -78,7 +78,7 @@ function StatusPage() {
}, [id, uiState !== 'loading']);
const scrollOffsets = useRef();
const initContext = () => {
const initContext = ({ reloadHero } = {}) => {
console.debug('initContext', id);
setUIState('loading');
let heroTimer;
@ -114,7 +114,7 @@ function StatusPage() {
const hasStatus = !!snapStates.statuses[sKey];
let heroStatus = snapStates.statuses[sKey];
if (hasStatus) {
if (hasStatus && !reloadHero) {
console.debug('Hero status is cached');
} else {
try {
@ -277,7 +277,9 @@ function StatusPage() {
const apiCache = await caches.open('api');
await apiCache.delete(contextURL, { ignoreVary: true });
return initContext();
return initContext({
reloadHero: true,
});
} catch (e) {
console.error(e);
}