forked from 1b-agent/opencadstudio-upstream
fix: close the review findings on the restore-all/deep-links/PWA wave
Two reviewers, no blockers, two majors — all fixed.
- The remembered-tab focus after a Restore-all batch fired at the
message boundary, but the LAST restore's tab inserts one async round
later (its OPFS recent-cache write precedes the insertion) and the
insertion's own activation overwrote the selection. The focus flag
now also consumes at the insertion point, so the batch focus holds
in the common all-success case.
- The service worker cached ANY successful in-scope navigation under
the shell key — a direct navigation to a font or JSON would be
served as the app shell for every offline navigation until the next
online visit. Only the scope root caches as the shell now.
Also: '/app/' gets its own web app manifest (the previous commit's
'installable' claim was true only of the marketing site, whose
start_url sits OUTSIDE the service worker's scope — an installed app
opened offline showed an error page). Its icon is the
existing assets/logo.svg, copied next to the page.
(cherry picked from commit 369e2c8b)
Ported onto main (#1717 review): the build-web.sh and README hunks stay
out with the wrapper.
This commit is contained in:
1 parent
6af8d8ba8c
commit
0459f20129
5 files changed
+42
-6
No files matched your search
+15
-4
@@ -2019,6 +2019,15 @@ impl OpenCADStudio {
|
||||
self.apply_display_defaults(idx);
|
||||
idx
|
||||
};
|
||||
// A Restore-all batch's LAST restore inserts its tab here — one
|
||||
// async round AFTER its settle message. The focus flag therefore
|
||||
// also fires here: the message-boundary hook alone could run
|
||||
// before this insertion and be overwritten by it.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
if self.web_session_focus_pending && self.web_autosave_restore_all_remaining == 0 {
|
||||
self.web_session_focus_pending = false;
|
||||
self.select_remembered_session_tab();
|
||||
}
|
||||
|
||||
// Missing-on-open: neutral command-line notice plus a flag
|
||||
// the Reference Manager reads. Never an auto-open modal.
|
||||
@@ -4176,19 +4185,19 @@ impl OpenCADStudio {
|
||||
/// from the after-message hook (`web_session_focus_pending`), so the
|
||||
/// whole settle batch — including the last tab insertion — is done.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub(super) fn select_remembered_session_tab(&mut self) {
|
||||
pub(super) fn select_remembered_session_tab(&mut self) -> Task<Message> {
|
||||
let Some(session) = self.web_session.as_ref() else {
|
||||
return;
|
||||
return Task::none();
|
||||
};
|
||||
let Some(remembered) = session.tabs.get(session.active) else {
|
||||
return;
|
||||
return Task::none();
|
||||
};
|
||||
let recovered = crate::io::web_autosave::recovered_name(remembered);
|
||||
let Some(index) = self.tabs.iter().position(|tab| {
|
||||
let name = tab.tab_display_name();
|
||||
name == remembered.as_str() || name == recovered
|
||||
}) else {
|
||||
return;
|
||||
return Task::none();
|
||||
};
|
||||
self.active_tab = index;
|
||||
// The active tab changed under the ribbon; re-sync its chips like
|
||||
@@ -4196,6 +4205,8 @@ impl OpenCADStudio {
|
||||
self.sync_ribbon_layers();
|
||||
self.sync_ribbon_styles();
|
||||
self.sync_ribbon_from_selection();
|
||||
|
||||
Task::none()
|
||||
}
|
||||
|
||||
/// Remember the open-tab list (names + active index) in localStorage —
|
||||
|
||||
@@ -487,7 +487,7 @@ impl OpenCADStudio {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
if self.web_session_focus_pending {
|
||||
self.web_session_focus_pending = false;
|
||||
self.select_remembered_session_tab();
|
||||
return self.select_remembered_session_tab();
|
||||
}
|
||||
self.sync_open_command_history();
|
||||
// Close the document-level first-touch transaction started by
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="manifest" href="app.webmanifest" />
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="robots" content="noindex, follow" />
|
||||
@@ -46,6 +47,8 @@
|
||||
<link data-trunk rel="copy-file" href="web/locale-labels.json" />
|
||||
<link data-trunk rel="copy-file" href="web/ocs-control.js" />
|
||||
<link data-trunk rel="copy-file" href="web/sw.js" />
|
||||
<link data-trunk rel="copy-file" href="web/app.webmanifest" />
|
||||
<link data-trunk rel="copy-file" href="assets/logo.svg" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="loading">
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "Open CAD Studio",
|
||||
"short_name": "OCS",
|
||||
"description": "A free CAD editor for DWG and DXF drawings.",
|
||||
"start_url": "./",
|
||||
"scope": "./",
|
||||
"display": "standalone",
|
||||
"background_color": "#1e1e1e",
|
||||
"theme_color": "#1e1e1e",
|
||||
"icons": [
|
||||
{
|
||||
"src": "logo.svg",
|
||||
"sizes": "any",
|
||||
"type": "image/svg+xml",
|
||||
"purpose": "any"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -89,9 +89,13 @@ self.addEventListener("fetch", (event) => {
|
||||
event.respondWith(
|
||||
(async () => {
|
||||
const cache = await caches.open(CACHE_NAME);
|
||||
// Only the scope root is the app shell: caching any other in-scope
|
||||
// navigation here would store e.g. a font or JSON body under the
|
||||
// shell key and serve it for every offline navigation.
|
||||
const isShell = new URL(request.url).pathname === SHELL_URL.pathname;
|
||||
try {
|
||||
const fresh = await fetch(request);
|
||||
await put(cache, SHELL_URL, fresh);
|
||||
if (isShell) await put(cache, SHELL_URL, fresh);
|
||||
return fresh;
|
||||
} catch {
|
||||
const cached = await cache.match(SHELL_URL);
|
||||
|
||||
Reference in new issue
Block a user