fix: bind Tomorrow conflict recovery to operator account
CI / lint (pull_request) Successful in 3m36s
CI / build-release (pull_request) Successful in 8s
CI / browser-journey (pull_request) Successful in 3m50s
CI / release-candidate (pull_request) Has been skipped

This commit is contained in:
timmy committed 2026-08-20 04:01:25 +00:00
1 parent 16a6ee1136
commit 059722de6c
2 files changed
+38 -6

No files matched your search

+7 -6
View File
@@ -63,14 +63,15 @@ function createTomorrowPlan({fetchJson,localDate,timeZone,storage,getLogin}={})
}).catch(async error=>{
if(error?.status===409) {
const remote=await fetchJson('api/v1/tomorrow');
lastConflict={local:pending(),remote:{...remote,ids:[...remote.ids],estimates:{...(remote.estimates||{})}}};
lastConflict={key,local:pending(),remote:{...remote,ids:[...remote.ids],estimates:{...(remote.estimates||{})}}};
}
throw error;
}).finally(()=>{flushing=null;});
return flushing;
}
async function keepLocal() {
if(!lastConflict) return false;
if(!lastConflict||lastConflict.key!==storageKey()) return false;
const conflictKey=lastConflict.key;
const local={...lastConflict.local,ids:[...lastConflict.local.ids],estimates:{...lastConflict.local.estimates}};
const body=deliveryBody({...local,base_revision:lastConflict.remote.revision});
try {
@@ -84,13 +85,13 @@ function createTomorrowPlan({fetchJson,localDate,timeZone,storage,getLogin}={})
} catch(error) {
if(error?.status===409) {
const remote=await fetchJson('api/v1/tomorrow');
lastConflict={local,remote:{...remote,ids:[...remote.ids],estimates:{...(remote.estimates||{})}}};
lastConflict={key:conflictKey,local,remote:{...remote,ids:[...remote.ids],estimates:{...(remote.estimates||{})}}};
}
throw error;
}
}
function useRemote() {
if(!lastConflict) return false;
if(!lastConflict||lastConflict.key!==storageKey()) return false;
const remote=lastConflict.remote;
const key=storageKey();
if(key&&storage) storage.removeItem(key);
@@ -162,8 +163,8 @@ function createTomorrowPlan({fetchJson,localDate,timeZone,storage,getLogin}={})
return {run,stop(){if(timer!==null)clearTimer(timer);timer=null;}};
}
function conflict() {
return lastConflict&&{local:{...lastConflict.local,ids:[...lastConflict.local.ids],estimates:{...lastConflict.local.estimates}},
remote:{...lastConflict.remote,ids:[...lastConflict.remote.ids],estimates:{...lastConflict.remote.estimates}}};
return lastConflict?.key===storageKey()?{local:{...lastConflict.local,ids:[...lastConflict.local.ids],estimates:{...lastConflict.local.estimates}},
remote:{...lastConflict.remote,ids:[...lastConflict.remote.ids],estimates:{...lastConflict.remote.estimates}}}:null;
}
return {adopt,load,save,stage,pending,flush,conflict,keepLocal,useRemote,promote,state,summary,nextLocalDate,startLifecycle};
}