fix: harden favorites storage recovery
This commit is contained in:
@@ -245,6 +245,14 @@ function getChromeLocalStorage(): ChromeStorageLocalArea {
|
||||
|
||||
function normalizeState(value: unknown, now: () => string): FavoritesStateV1 {
|
||||
const source = isRecord(value) ? value : {};
|
||||
if (source.version !== 1) {
|
||||
return {
|
||||
creators: [],
|
||||
folders: [],
|
||||
memberships: [],
|
||||
version: 1
|
||||
};
|
||||
}
|
||||
const folders = normalizeFolders(source.folders, now);
|
||||
const creators = normalizeCreators(source.creators, now);
|
||||
const knownFolderIds = new Set(folders.map((folder) => folder.id));
|
||||
|
||||
Reference in New Issue
Block a user