fix(#253 PR2): SPA lint — move conflict-reload gating out of loadItems
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 5s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 5m15s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 6m19s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 5s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 5m15s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 6m19s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
The prior fix set setItemsLoading/setItemsLoaded at the top of loadItems, but the activeId effect calls loadItems synchronously → react-hooks/set-state-in-effect lint error (Main Lint SPA, the real CI failure). Move the not-loaded/loading gating into reloadAfterConflict (an event handler, lint-clean), which is exactly the 412 conflict- reload path Codex's Medium-3 targeted; canEdit stays false through that reload window. Behavior unchanged; the normal switch/initial-load paths (guarded separately by the #242 dirty-guard) are left untouched. Local: lint clean, vitest 667, check:api no drift, full dotnet solution test green.
This commit is contained in:
@@ -137,12 +137,6 @@ export function SchedulesScreen() {
|
||||
// ---- Load items for the active schedule --------------------------------
|
||||
const loadItems = useCallback((scheduleId: number) => {
|
||||
const seq = ++itemSeq.current;
|
||||
// Mark not-loaded/loading up front so `canEdit` (itemsLoaded && !saving) is false for the whole
|
||||
// (re)load window — including the 412 conflict reload. Otherwise a slow reload GET would leave the
|
||||
// rejected/stale draft editable, and edits made during that window would be silently discarded when
|
||||
// the reload re-seeds the baseline (issue #253 / #242 mutation gating).
|
||||
setItemsLoading(true);
|
||||
setItemsLoaded(false);
|
||||
getScheduleItemsWithMeta(scheduleId)
|
||||
.then(({ data: response, etag }) => {
|
||||
if (!activeRef.current || itemSeq.current !== seq) {
|
||||
@@ -372,6 +366,13 @@ export function SchedulesScreen() {
|
||||
setConflictOpen(false);
|
||||
setMutationError(null);
|
||||
if (activeId != null) {
|
||||
// Mark not-loaded/loading before kicking off the reload so `canEdit` (itemsLoaded && !saving) is
|
||||
// false for the whole conflict-reload window. Otherwise a slow reload GET would leave the rejected
|
||||
// stale draft editable, and edits made during that window would be silently discarded when the
|
||||
// reload re-seeds the baseline (issue #253 / #242 mutation gating). Set here (an event handler)
|
||||
// rather than inside loadItems, which the activeId effect calls synchronously (react-hooks lint).
|
||||
setItemsLoading(true);
|
||||
setItemsLoaded(false);
|
||||
loadItems(activeId);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user