From ec2907c0a674cb9fbfe3ca5441ef0d1c8c1c8b67 Mon Sep 17 00:00:00 2001 From: HF Date: Mon, 5 Sep 2022 10:59:06 +0200 Subject: [PATCH 1/3] fix mute button notification --- src/controls/keypress.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/keypress.js b/src/controls/keypress.js index 6e1634cf..7537b212 100644 --- a/src/controls/keypress.js +++ b/src/controls/keypress.js @@ -78,7 +78,7 @@ function createKeyPressHandler(store) { return; case 'm': store.dispatch(toggleMute()); - store.dispatch(notify((store.getState().audio.mute) + store.dispatch(notify((store.getState().gui.mute) ? t`Muted Sound` : t`Unmuted Sound`)); return; From 47ac68c34adb6897d2bce69da17e9fb964030972 Mon Sep 17 00:00:00 2001 From: HF Date: Mon, 5 Sep 2022 11:10:22 +0200 Subject: [PATCH 2/3] broadcast messages from one popup over parent to others --- src/core/popUps.js | 10 ++++++++-- src/store/middleware/parent.js | 4 +++- src/store/middleware/popUps.js | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/core/popUps.js b/src/core/popUps.js index 609a9f88..dec3c2c1 100644 --- a/src/core/popUps.js +++ b/src/core/popUps.js @@ -24,7 +24,11 @@ class PopUps { if (~pos) this.wins.splice(pos, 1); } - dispatch(msg) { + /* + * send message to all popups + * except the ignore one + */ + dispatch(msg, ignore = null) { const { wins } = this; try { for (let i = 0; i < wins.length; i += 1) { @@ -34,7 +38,9 @@ class PopUps { i -= 1; continue; } - win.postMessage(msg, this.origin); + if (win !== ignore) { + win.postMessage(msg, this.origin); + } } } catch { return false; diff --git a/src/store/middleware/parent.js b/src/store/middleware/parent.js index 318e2bce..3b527253 100644 --- a/src/store/middleware/parent.js +++ b/src/store/middleware/parent.js @@ -17,7 +17,9 @@ window.addEventListener('beforeunload', () => { export default (store) => (next) => (action) => { if (action instanceof MessageEvent) { - if (action.origin !== origin) { + if (action.origin !== origin + || !action.data.type + ) { return null; } if (action.data.type === 't/UNLOAD') { diff --git a/src/store/middleware/popUps.js b/src/store/middleware/popUps.js index 98eab20b..1f9622a2 100644 --- a/src/store/middleware/popUps.js +++ b/src/store/middleware/popUps.js @@ -9,7 +9,9 @@ import popUps from '../../core/popUps'; export default (store) => (next) => (action) => { if (action instanceof MessageEvent) { - if (action.origin !== window.location.origin) { + if (action.origin !== window.location.origin + || !action.data.type + ) { return null; } if (action.data.type === 't/UNLOAD') { @@ -23,6 +25,8 @@ export default (store) => (next) => (action) => { ); popUps.add(action.source); console.log('popup added'); + } else if (action.data.type.startsWith('s/')) { + popUps.dispatch(action.data, action.source); } return next(action.data); } From dca577cd79b70200ecdfe586f51502ee39ae0991 Mon Sep 17 00:00:00 2001 From: HF Date: Mon, 5 Sep 2022 11:38:34 +0200 Subject: [PATCH 3/3] open canvas links from popups in parent --- src/client.js | 1 + src/components/MdLink.jsx | 8 +++++++- src/store/middleware/parent.js | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/client.js b/src/client.js index a48a71ca..f6409bfd 100644 --- a/src/client.js +++ b/src/client.js @@ -119,6 +119,7 @@ persistStore(store, {}, () => { (function load() { const onLoad = () => { + window.name = 'main'; renderApp(document.getElementById('app'), store); const onKeyPress = createKeyPressHandler(store); diff --git a/src/components/MdLink.jsx b/src/components/MdLink.jsx index bc26e0ff..f38dee8d 100644 --- a/src/components/MdLink.jsx +++ b/src/components/MdLink.jsx @@ -9,6 +9,7 @@ import { HiArrowsExpand, HiStop } from 'react-icons/hi'; import { getLinkDesc } from '../core/utils'; import EMBEDS from './embeds'; +import { isPopUp } from './windows/popUpAvailable'; const titleAllowed = [ 'odysee', @@ -27,8 +28,13 @@ const MdLink = ({ href, title, refEmbed }) => { // treat pixelplanet links seperately if (desc === window.location.hostname && href.includes('/#')) { const coords = href.substring(href.indexOf('/#') + 1); + if (isPopUp() && window.opener && !window.opener.closed) { + return ( + {title || coords} + ); + } return ( - {title || coords} + {title || coords} ); } diff --git a/src/store/middleware/parent.js b/src/store/middleware/parent.js index 3b527253..58e1d74c 100644 --- a/src/store/middleware/parent.js +++ b/src/store/middleware/parent.js @@ -9,7 +9,7 @@ import { load, unload } from '../actions'; const { origin } = window.location; window.addEventListener('beforeunload', () => { - if (window.opener && !window.closed) { + if (window.opener && !window.opener.closed) { window.opener.postMessage(unload(), origin); } });