The saved match configuration or default.
export function getMatchConfig(): MatchConfig {
try {
const config = storage.getItem(STORAGE_KEYS.MATCH_CONFIG);
if (!config) {
return DEFAULT_MATCH_CONFIG;
}
const parsed = JSON.parse(config);
// Migrate custom rules before returning if they exist
if (parsed.customRules) {
const skipRules = Array.isArray(parsed.customRules.skipRules)
? parsed.customRules.skipRules.map(migrateCustomRule)
: [];
const acceptRules = Array.isArray(parsed.customRules.acceptRules)
? parsed.customRules.acceptRules.map(migrateCustomRule)
: [];
parsed.customRules = { skipRules, acceptRules };
}
// Merge with defaults to ensure new fields like customRules are always populated
// Support legacy property names by mapping older keys to the new ones
if (
typeof parsed.ignoreOneShots === "boolean" &&
parsed.shouldIgnoreOneShots === undefined
) {
parsed.shouldIgnoreOneShots = parsed.ignoreOneShots;
delete parsed.ignoreOneShots;
}
if (
typeof parsed.ignoreAdultContent === "boolean" &&
parsed.shouldIgnoreAdultContent === undefined
) {
parsed.shouldIgnoreAdultContent = parsed.ignoreAdultContent;
delete parsed.ignoreAdultContent;
}
return { ...DEFAULT_MATCH_CONFIG, ...parsed };
} catch (error) {
console.error(
"[Storage] Error retrieving match config from storage",
error,
);
return DEFAULT_MATCH_CONFIG;
}
}
Retrieves match configuration, using defaults if not found.