Stories: Back into a deleted story's entry clears ?story= from the address

This commit is contained in:
Sameh Khamis committed 2026-11-16 13:36:13 -08:00
1 parent 7a0b649bf5
commit 85c9f95838
2 files changed
+30 -7

No files matched your search

+12 -7
View File
@@ -268,13 +268,18 @@ export function createStoriesController({
? controller.open({ fromHistory: true })
: controller.backToExplore({ fromHistory: true, returningToExplore });
else if (store.mode !== 'closed') controller.close({ fromHistory: true });
else if (pendingView) {
// Another browser navigation landed while the scene was stopping.
// The destination owns the globe now, so discard the earlier restore.
pendingView = null;
closeGeneration += 1;
document.body.classList.remove('stories-mode');
shareLink()?.holdWrites?.(false);
else {
// An entry for a story that is gone (deleted since) opens nothing;
// its ?story= must not stay in the address for the next share link.
if (id) clearStoriesUrl();
if (pendingView) {
// Another browser navigation landed while the scene was stopping.
// The destination owns the globe now, so discard the earlier restore.
pendingView = null;
closeGeneration += 1;
document.body.classList.remove('stories-mode');
shareLink()?.holdWrites?.(false);
}
}
}
addEventListener('popstate', onPopState);
+18
View File
@@ -948,6 +948,24 @@ test('Close after Back to Explore still puts AUTHORING’s selection back', asyn
controller.destroy();
});
test('Back into the entry of a deleted story, with Stories closed, clears ?story=', () => {
const { controller, store } = setup();
assert.equal(store.mode, 'closed');
history.replaceState(
{ gevStories: { story: 'gev:gone', depth: 2, explore: 1 } },
'',
'/?story=gev%3Agone&storyTime=12#lat=1',
);
dispatchEvent(new PopStateEvent('popstate'));
assert.equal(store.mode, 'closed', 'nothing opens');
const url = new URL(location.href);
assert.equal(url.searchParams.has('story'), false);
assert.equal(url.searchParams.has('storyTime'), false);
assert.equal(url.hash, '#lat=1', 'the globe state stays');
assert.equal(history.state?.gevStories, undefined);
controller.destroy();
});
test('unsaved scenes appear as local drafts and disappear when deleted', () => {
setActivePinia(createPinia());
history.replaceState(null, '', '/');