fix: align task due dates to the right
ci / gitleaks (push) Successful in 7s
ci / docker (push) Successful in 3m34s

This commit is contained in:
2026-09-10 17:01:24 +08:00
parent 0345fbe73c
commit 1366f302ec
8 changed files with 183 additions and 24 deletions
+28 -1
View File
@@ -141,6 +141,28 @@ export function nextTotalAfterLocalTaskAdd(total: number) {
return Math.max(0, Number(total) || 0) + 1
}
export function nextTotalAfterLocalTaskRemoval(total: number, removed = 1) {
return Math.max(0, (Number(total) || 0) - Math.max(0, removed))
}
export type TrashMutationResult =
| { mutated: false; refreshed: false; error: unknown }
| { mutated: true; refreshed: boolean }
export async function performTrashMutation(
mutate: () => Promise<unknown>,
reconcileLocal: () => void,
refresh: () => Promise<boolean>,
): Promise<TrashMutationResult> {
try {
await mutate()
} catch (error) {
return { mutated: false, refreshed: false, error }
}
reconcileLocal()
return { mutated: true, refreshed: await refresh() }
}
export function clampFabPosition(x: number, y: number, viewportWidth: number, viewportHeight: number, size = 52, margin = 14, bottomReserved = 74) {
return {
x: Math.min(Math.max(x, margin), Math.max(margin, viewportWidth - size - margin)),
@@ -190,14 +212,19 @@ export async function runLatestRequest<T>(
},
) {
const generation = beginLatestRequest(key)
let committed = false
try {
const value = await request()
if (isLatestRequest(key, generation)) callbacks.success(value)
if (isLatestRequest(key, generation)) {
callbacks.success(value)
committed = true
}
} catch (reason) {
if (isLatestRequest(key, generation)) callbacks.error(reason)
} finally {
if (isLatestRequest(key, generation)) callbacks.finally()
}
return committed
}
export type MutationReconciler<TContext> = {