The saved match results or null if not found or incompatible.
export function getSavedMatchResults(): MatchResult[] | null {
try {
// Check cache version compatibility
const savedVersion = parseInt(
storage.getItem(STORAGE_KEYS.CACHE_VERSION) || "0",
10,
);
if (savedVersion !== CURRENT_CACHE_VERSION && savedVersion !== 0) {
console.warn(
`Cache version mismatch. Saved: ${savedVersion}, Current: ${CURRENT_CACHE_VERSION}`,
);
return null; // Consider the cache invalid if versions don't match
}
const savedResults = storage.getItem(STORAGE_KEYS.MATCH_RESULTS);
return savedResults ? JSON.parse(savedResults) : null;
} catch (error) {
console.error("Error retrieving saved match results from storage", error);
return null;
}
}
Gets saved match results from storage, checking cache version compatibility.