diff --git a/components/page-actions.js b/components/page-actions.js index 9eb8918..a0fd001 100644 --- a/components/page-actions.js +++ b/components/page-actions.js @@ -237,7 +237,16 @@ export class PageActions extends HTMLElement { 'm-forms-button-group' ) bGroup.addPrimary(this.text.save, () => { - this.page.settings = settingsEl.data + const settingsData = settingsEl.data + this.page.settings = settingsData + for (const dir of ['outbound', 'inbound']) { + const otherDir = ( + dir === 'outbound' ? 'inbound' : 'outbound' + ) + this.applyInverseSettings( + settingsData, dir, otherDir + ) + } dialog.close() this.dispatchEvent(new CustomEvent( 'settings-change', {bubbles: true, composed: true} @@ -250,6 +259,32 @@ export class PageActions extends HTMLElement { dialog.open() } + applyInverseSettings(settingsData, dir, otherDir) { + const selfEntries = Object.entries( + settingsData.connections[dir] + ) + for (const [path, access] of selfEntries) { + const key = 'settings/page:' + path + let val = localStorage.getItem(key) + try { + if (val !== null) { + val = JSON.parse(val) + } + } catch (err) { + // ignore + } + const data = val ?? {} + data.connections = data.connections ?? {} + data.connections[otherDir] = ( + data.connections[otherDir] ?? {} + ) + data.connections[otherDir][this.path] = access + localStorage.setItem( + key, JSON.stringify(data) + ) + } + } + get language() { return this._language }