mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-03 04:42:39 +02:00
fix: stabilize sync process by rounding cutoff date to midnight UTC and update cleanup logic for user databases
This commit is contained in:
parent
6989059e94
commit
dec85b6417
2 changed files with 67 additions and 19 deletions
|
|
@ -38,10 +38,14 @@ function deduplicateAndSort(items: InboxItem[]): InboxItem[] {
|
|||
|
||||
/**
|
||||
* Calculate the cutoff date for sync window
|
||||
* IMPORTANT: Rounds to the start of the day (midnight UTC) to ensure stable values
|
||||
* across re-renders. Without this, millisecond differences cause multiple syncs!
|
||||
*/
|
||||
function getSyncCutoffDate(): string {
|
||||
const cutoff = new Date();
|
||||
cutoff.setDate(cutoff.getDate() - SYNC_WINDOW_DAYS);
|
||||
// Round to start of day to prevent millisecond differences causing duplicate syncs
|
||||
cutoff.setUTCHours(0, 0, 0, 0);
|
||||
return cutoff.toISOString();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue