The media entry to check for changes.
Sync configuration with priority settings.
True if the entry has changes that should be synced.
export function hasChanges(
entry: AniListMediaEntry,
syncConfig: SyncConfig,
): boolean {
// New entry: not in userLibrary
if (!entry.previousValues) return true;
// Completed and preserve setting: skip
if (
entry.previousValues.status === "COMPLETED" &&
syncConfig.preserveCompletedStatus
) {
return false;
}
// Status change
const shouldUpdateStatus = syncConfig.prioritizeAniListStatus
? false
: entry.status !== entry.previousValues.status;
// Progress change
const shouldUpdateProgress = syncConfig.prioritizeAniListProgress
? entry.progress > entry.previousValues.progress
: entry.progress !== entry.previousValues.progress;
// Score change
const anilistScore = Number(entry.previousValues.score || 0);
const kenmeiScore = Number(entry.score || 0);
const shouldUpdateScore =
entry.previousValues.status === "COMPLETED" &&
syncConfig.preserveCompletedStatus
? false
: (() => {
if (syncConfig.prioritizeAniListScore && anilistScore > 0) {
return false;
}
return (
kenmeiScore > 0 &&
(anilistScore === 0 || Math.abs(kenmeiScore - anilistScore) >= 0.5)
);
})();
// Privacy change
const shouldUpdatePrivacy =
syncConfig.setPrivate && !entry.previousValues.private;
return (
shouldUpdateStatus ||
shouldUpdateProgress ||
shouldUpdateScore ||
shouldUpdatePrivacy
);
}
Determine if an entry has actual changes to sync based on config priorities. Respects preserveCompletedStatus, prioritization settings, and threshold tolerance.