The deep equality check with _.isEqual() on potentially large profile data objects could be expensive. Consider comparing modification timestamps or checksums first before doing a full object comparison.
const remoteModifiedAt = new Date(remoteProfileData.meta.modifiedAt ?? 0);
const lastSyncTime = new Date(app.lastSyncTime ?? 0);
const syncDecisionFromTime = this.getSyncDecision(localModifiedAt, remoteModifiedAt, lastSyncTime);
let syncDecision: SyncDecision;
if (app.meta.modifiedAt === remoteProfileData.meta.modifiedAt) {
// Only do deep equality check if timestamps are equal
syncDecision = (_.isEqual(remoteProfileData, app.exportProfile(false))) ? SyncDecision.none : syncDecisionFromTime;
} else {
syncDecision = syncDecisionFromTime;
}
Originally posted by @Copilot in #37 (comment)
The deep equality check with _.isEqual() on potentially large profile data objects could be expensive. Consider comparing modification timestamps or checksums first before doing a full object comparison.
Originally posted by @Copilot in #37 (comment)