Merge the Posterverse shell's ownAddress (shareable pages P2)

This commit is contained in:
Doxa Maps 2026-10-03 06:30:18 +00:00
commit 86a601b3b2

View file

@ -74,7 +74,7 @@ import BackToTopButton from '@map/components/BackToTopButton.vue'
import ShellLanguageMenu from '@map/components/ShellLanguageMenu.vue'
import { saveLocale } from '@map/layouts/app-wrapper-material/languages.js'
import { loadScriptOnce, whenTagDefined } from '@map/utils/embedScript.js'
import { readViewKeys, writeViewKeys, onAddressChange, urlOwnerOf } from '@map/composables/useViewAddress.js'
import { readViewKeys, writeViewKeys, onAddressChange, urlOwnerOf, ownAddress } from '@map/composables/useViewAddress.js'
import { translate, LOCALES } from './src/strings.js'
import { SECTIONS, TABS, resolveTabs } from './src/tabs.js'
@ -233,6 +233,9 @@ export default defineComponent({
const want = this.requestedTab()
const known = !want || this.tabs.some((t) => t.id === want)
this.select(this.initialIndex(), { firstPaint: true, fromHistory: !known })
// A nested plugin's choice inside a tab (?pane=, ?place=) reaches the address through the owner: recorded
// only while this page owns its address, never a tab switch, and the event stops here.
this._offOwn = ownAddress(this.$el, () => urlOwnerOf(this.cfg))
// Back / Forward re-apply the tab from the address and never write (writing would lose Forward).
this._offAddress = onAddressChange(({ tab }) => {
const i = this.tabs.findIndex((t) => t.id === tab)
@ -243,6 +246,7 @@ export default defineComponent({
beforeUnmount() {
if (this._langObs) { this._langObs.disconnect(); this._langObs = null }
if (this._offAddress) { this._offAddress(); this._offAddress = null }
if (this._offOwn) { this._offOwn(); this._offOwn = null }
},
methods: {
tr(key, params) { return translate(this.uiLocale, key, params) },