The sync report to save.
export function saveSyncReportToHistory(report: SyncReport): void {
try {
// Get existing history from localStorage
const storageKey = "anilist_sync_history";
const existingHistoryJson = localStorage.getItem(storageKey);
const existingHistory: SyncReport[] = existingHistoryJson
? JSON.parse(existingHistoryJson)
: [];
// Add new report to history (limit to most recent 10)
const updatedHistory = [report, ...existingHistory].slice(0, 10);
// Save back to localStorage
localStorage.setItem(storageKey, JSON.stringify(updatedHistory));
console.log("Sync report saved to history");
} catch (error) {
console.error("Failed to save sync report to history:", error);
}
}
Saves a sync report to localStorage for later reference.