bandaid fix popups api

pull/98/head
dperolio 2 years ago
parent 1d6c8aa784
commit 1163d4fccd
No known key found for this signature in database
GPG Key ID: 4191689562D51409

@ -8,7 +8,7 @@
import { PopupWindow, Titlebar, Spinner } from '@vizality/components';
import React, { memo, useState, useEffect } from 'react';
import { getModule } from '@vizality/webpack';
import { getModule, FluxDispatcher } from '@vizality/webpack';
import { Events } from '@vizality/constants';
import { API } from '@vizality/entities';
@ -56,9 +56,11 @@ export default class Popups extends API {
options.top = options.top || y;
options.left = options.left || x;
if (window.popouts.has(popup.popupId)) {
throw new Error(`Popup with ID "${popup.popupId}" already active!`);
}
/*
* if (window.popouts.has(popup.popupId)) {
* throw new Error(`Popup with ID "${popup.popupId}" already active!`);
* }
*/
const PopupContent = memo(props => {
const [ loading, setLoading ] = useState(true);
@ -86,22 +88,25 @@ export default class Popups extends API {
allowtransparency={true}
sandbox={sandbox}
/>
: children
: (
<div className='vz-popup-content'>
{children}
</div>
)
}
</div>
</div>
);
});
return new Promise(() => {
const popupModule = getModule('setAlwaysOnTop', 'open');
popupModule.open(`DISCORD_${popup.popupId}`, key => {
return (
<PopupWindow windowKey={key} {...popup}>
<PopupContent windowKey={key} {...popup}>
{popup.render && !popup.url && <Render {...popup} />}
</PopupContent>
</PopupWindow>
<PopupContent windowKey={key} {...popup}>
{popup.render && !popup.url && <Render {...popup} />}
</PopupContent>
);
}, options);
});
@ -141,10 +146,4 @@ export default class Popups extends API {
return this.error(err);
}
}
stop () {
this.closeAllPopups();
this.removeAllListeners();
delete vizality.api.popups;
}
}

@ -36,12 +36,16 @@ export default class QuickCode extends Builtin {
}
async _openCustomCSS () {
vizality.api.popups.openPopup({
popupId: 'VIZALITY_CUSTOM_CSS',
title: 'Quick Code - CSS',
titlebarType: 'WINDOWS',
render: props => <QuickCodePage builtin={this} popout={true} {...props} />
});
try {
vizality.api.popups.openPopup({
popupId: 'VIZALITY_CUSTOM_CSS',
title: 'Quick Code - CSS',
titlebarType: 'WINDOWS',
render: props => <QuickCodePage builtin={this} popout={true} {...props} />
});
} catch (err) {
this.error(err);
}
}
async _loadCustomCSS () {

@ -3,15 +3,12 @@ import { Regexes } from '@vizality/constants';
import AsyncComponent from './AsyncComponent';
export default AsyncComponent.from((async () => {
export default AsyncComponent.from((async props => {
const DiscordPopoutWindow = getModule(m => m.DecoratedComponent?.render);
class PopupWindow extends DiscordPopoutWindow {
constructor (props) {
if (!props.withTitleBar) {
// Enforce it
props.withTitleBar = false;
}
super(props);
props.withTitleBar = true;
}
componentDidMount () {

Loading…
Cancel
Save