Merge branch 'devel'

This commit is contained in:
HF 2022-09-05 11:46:43 +02:00
commit b7d2d43d3e
6 changed files with 26 additions and 7 deletions

View File

@ -119,6 +119,7 @@ persistStore(store, {}, () => {
(function load() { (function load() {
const onLoad = () => { const onLoad = () => {
window.name = 'main';
renderApp(document.getElementById('app'), store); renderApp(document.getElementById('app'), store);
const onKeyPress = createKeyPressHandler(store); const onKeyPress = createKeyPressHandler(store);

View File

@ -9,6 +9,7 @@ import { HiArrowsExpand, HiStop } from 'react-icons/hi';
import { getLinkDesc } from '../core/utils'; import { getLinkDesc } from '../core/utils';
import EMBEDS from './embeds'; import EMBEDS from './embeds';
import { isPopUp } from './windows/popUpAvailable';
const titleAllowed = [ const titleAllowed = [
'odysee', 'odysee',
@ -27,8 +28,13 @@ const MdLink = ({ href, title, refEmbed }) => {
// treat pixelplanet links seperately // treat pixelplanet links seperately
if (desc === window.location.hostname && href.includes('/#')) { if (desc === window.location.hostname && href.includes('/#')) {
const coords = href.substring(href.indexOf('/#') + 1); const coords = href.substring(href.indexOf('/#') + 1);
if (isPopUp() && window.opener && !window.opener.closed) {
return (
<a href={`/${coords}`} target="main">{title || coords}</a>
);
}
return ( return (
<a href={`./${coords}`}>{title || coords}</a> <a href={`/${coords}`}>{title || coords}</a>
); );
} }

View File

@ -78,7 +78,7 @@ function createKeyPressHandler(store) {
return; return;
case 'm': case 'm':
store.dispatch(toggleMute()); store.dispatch(toggleMute());
store.dispatch(notify((store.getState().audio.mute) store.dispatch(notify((store.getState().gui.mute)
? t`Muted Sound` ? t`Muted Sound`
: t`Unmuted Sound`)); : t`Unmuted Sound`));
return; return;

View File

@ -24,7 +24,11 @@ class PopUps {
if (~pos) this.wins.splice(pos, 1); 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; const { wins } = this;
try { try {
for (let i = 0; i < wins.length; i += 1) { for (let i = 0; i < wins.length; i += 1) {
@ -34,7 +38,9 @@ class PopUps {
i -= 1; i -= 1;
continue; continue;
} }
win.postMessage(msg, this.origin); if (win !== ignore) {
win.postMessage(msg, this.origin);
}
} }
} catch { } catch {
return false; return false;

View File

@ -9,7 +9,7 @@ import { load, unload } from '../actions';
const { origin } = window.location; const { origin } = window.location;
window.addEventListener('beforeunload', () => { window.addEventListener('beforeunload', () => {
if (window.opener && !window.closed) { if (window.opener && !window.opener.closed) {
window.opener.postMessage(unload(), origin); window.opener.postMessage(unload(), origin);
} }
}); });
@ -17,7 +17,9 @@ window.addEventListener('beforeunload', () => {
export default (store) => (next) => (action) => { export default (store) => (next) => (action) => {
if (action instanceof MessageEvent) { if (action instanceof MessageEvent) {
if (action.origin !== origin) { if (action.origin !== origin
|| !action.data.type
) {
return null; return null;
} }
if (action.data.type === 't/UNLOAD') { if (action.data.type === 't/UNLOAD') {

View File

@ -9,7 +9,9 @@ import popUps from '../../core/popUps';
export default (store) => (next) => (action) => { export default (store) => (next) => (action) => {
if (action instanceof MessageEvent) { if (action instanceof MessageEvent) {
if (action.origin !== window.location.origin) { if (action.origin !== window.location.origin
|| !action.data.type
) {
return null; return null;
} }
if (action.data.type === 't/UNLOAD') { if (action.data.type === 't/UNLOAD') {
@ -23,6 +25,8 @@ export default (store) => (next) => (action) => {
); );
popUps.add(action.source); popUps.add(action.source);
console.log('popup added'); console.log('popup added');
} else if (action.data.type.startsWith('s/')) {
popUps.dispatch(action.data, action.source);
} }
return next(action.data); return next(action.data);
} }