Add schema utils

This commit is contained in:
Jamie Kyle 2024-10-02 12:03:10 -07:00 committed by GitHub
parent c8a729f8be
commit b26466e59d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 674 additions and 151 deletions

View file

@ -62,6 +62,7 @@ import { ToastType } from '../types/Toast';
import { AbortableProcess } from '../util/AbortableProcess';
import type { WebAPICredentials } from './Types';
import { NORMAL_DISCONNECT_CODE } from './SocketManager';
import { parseUnknown } from '../util/schemas';
const THIRTY_SECONDS = 30 * durations.SECOND;
@ -107,7 +108,7 @@ export namespace AggregatedStats {
try {
const json = localStorage.getItem(key);
return json != null
? AggregatedStatsSchema.parse(JSON.parse(json))
? parseUnknown(AggregatedStatsSchema, JSON.parse(json) as unknown)
: createEmpty();
} catch (error) {
log.warn(