T1.1 (cont.) - F1: fill in the id-only stub, and resolve deep links in the bar
Completing T1.1. My first verification primed localStorage before loading each
page, which made both sources of truth agree and hid two remaining cases. Re-run
with genuinely cold storage, the app bar still showed "(unnamed)" on the field
view and "Select a project" on the console pages.
Two causes, both the same F1 shape - a page holding a copy the shared store
does not have:
1. field.js could only write {id} at boot (it needs the id synchronously, for
the per-project storage namespace), then resolved the full record into a
local PROJECT variable, rendered "Project: Job A" from it, and never
published it. The store kept the stub, so the bar read "(unnamed)".
setActive now fills a nameless record in from the cached project list, or
from the API when the cache has not loaded yet, and re-checks the id before
applying a slow response so it cannot overwrite a project the user has since
switched to. That fixes every caller of this shape rather than the one that
was caught - work-package-suite-app.js and wp-creation-app.js write the same
stub. field.js also publishes the record it already fetched, so the common
path costs no extra request.
2. admin.html and users.html have no project-resolution logic of their own, so
nothing read ?project= and a deep link left the bar on whatever was last
stored. The bar is the one component every chromed page has, so it resolves
the parameter once in wp-chrome.js rather than being taught to five pages.
Verified with localStorage cleared before every navigation: a cold deep link
now shows the project on field, SOP wizard, launcher, admin and users, and the
stored record carries the name rather than a stub.
The creator remains the one page with no app bar - it loads no chrome because
it renders as the iframe child. T7.1.
browser_check 71/71. f_items F1 FIXED.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -112,6 +112,25 @@
|
||||
}
|
||||
} catch (e) {}
|
||||
notifyActive(p || null);
|
||||
|
||||
// A caller that knew only the id leaves the store holding a stub, and every
|
||||
// reader then renders "(unnamed)" — field.js sets {id} on boot and resolves the
|
||||
// record into a variable of its own. Fill the stub in from the cached list, or
|
||||
// from the API when the cache has not loaded yet. The re-entry carries a name,
|
||||
// so it cannot loop; the id re-check stops a slow response from overwriting a
|
||||
// project the user has since switched to.
|
||||
if (p && p.id && !p.name) {
|
||||
var self = this;
|
||||
var cached = readLocal().filter(function (x) { return x.id === p.id; })[0];
|
||||
if (cached && cached.name) { self.setActive(cached); return; }
|
||||
try {
|
||||
if (self.get) {
|
||||
self.get(p.id).then(function (full) {
|
||||
if (full && full.name && self.getActiveId() === full.id) self.setActive(full);
|
||||
}).catch(function () {});
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
},
|
||||
|
||||
// Subscribe to active-project changes. Returns an unsubscribe function.
|
||||
|
||||
Reference in New Issue
Block a user