chore(lint): keep the fixes within the lint ratchets

No promise in a condition, sequential awaits through a reduce instead of a loop, no non-null assertions or any in the new tests, an awaited act, one options object for a stop edit and a handled rejection for the offline copy.
This commit is contained in:
Maurice
2026-11-23 16:09:34 +01:00
parent f6d52727f7
commit 8a9f5367b1
15 changed files with 65 additions and 31 deletions
@@ -362,11 +362,14 @@ export class DawarichSyncService {
* @txIndependent one stay at a time after its network read.
*/
private async rereadUnnamed(nameStay: StayNamer): Promise<void> {
for (const stay of nameStay.unnamed.slice(0, MAX_UNNAMED_STAY_REREADS)) {
// One after another: a read that finds the budget spent stops the rest.
await nameStay.unnamed.slice(0, MAX_UNNAMED_STAY_REREADS).reduce<Promise<boolean>>(async (going, stay) => {
if (!(await going)) return false;
const found = await nameStay.read(stay.startedAt, stay.endedAt);
if (found === undefined) return;
if (found === undefined) return false;
if (found !== null) await this.suggestions.renameNewVisit(stay.id, found);
}
return true;
}, Promise.resolve(true));
}
/**
@@ -47,7 +47,7 @@ export function tripEventSink(addons: AddonsService, orm: MikroORM | undefined,
return (tripId, event, meta) => {
const addonId = tripAddonOfEvent(event);
const before = queues.get(tripId);
if (!addonId && !before) return deliver(tripId, event, meta);
if (!addonId && before === undefined) return deliver(tripId, event, meta);
const ask = () => (addonId ? addons.isEnabledForTrip(tripId, addonId) : Promise.resolve(true));
const on = (orm && addonId ? withRequestContext(orm, ask) : ask()).catch(() => false);
const queued = (before ?? Promise.resolve())