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 { PopupWindow, Titlebar, Spinner } from '@vizality/components';
import React, { memo, useState, useEffect } from 'react'; import React, { memo, useState, useEffect } from 'react';
import { getModule } from '@vizality/webpack'; import { getModule, FluxDispatcher } from '@vizality/webpack';
import { Events } from '@vizality/constants'; import { Events } from '@vizality/constants';
import { API } from '@vizality/entities'; import { API } from '@vizality/entities';
@ -56,9 +56,11 @@ export default class Popups extends API {
options.top = options.top || y; options.top = options.top || y;
options.left = options.left || x; 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 PopupContent = memo(props => {
const [ loading, setLoading ] = useState(true); const [ loading, setLoading ] = useState(true);
@ -86,22 +88,25 @@ export default class Popups extends API {
allowtransparency={true} allowtransparency={true}
sandbox={sandbox} sandbox={sandbox}
/> />
: children : (
<div className='vz-popup-content'>
{children}
</div>
)
} }
</div> </div>
</div> </div>
); );
}); });
return new Promise(() => { return new Promise(() => {
const popupModule = getModule('setAlwaysOnTop', 'open'); const popupModule = getModule('setAlwaysOnTop', 'open');
popupModule.open(`DISCORD_${popup.popupId}`, key => { popupModule.open(`DISCORD_${popup.popupId}`, key => {
return ( return (
<PopupWindow windowKey={key} {...popup}> <PopupContent windowKey={key} {...popup}>
<PopupContent windowKey={key} {...popup}> {popup.render && !popup.url && <Render {...popup} />}
{popup.render && !popup.url && <Render {...popup} />} </PopupContent>
</PopupContent>
</PopupWindow>
); );
}, options); }, options);
}); });
@ -141,10 +146,4 @@ export default class Popups extends API {
return this.error(err); 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 () { async _openCustomCSS () {
vizality.api.popups.openPopup({ try {
popupId: 'VIZALITY_CUSTOM_CSS', vizality.api.popups.openPopup({
title: 'Quick Code - CSS', popupId: 'VIZALITY_CUSTOM_CSS',
titlebarType: 'WINDOWS', title: 'Quick Code - CSS',
render: props => <QuickCodePage builtin={this} popout={true} {...props} /> titlebarType: 'WINDOWS',
}); render: props => <QuickCodePage builtin={this} popout={true} {...props} />
});
} catch (err) {
this.error(err);
}
} }
async _loadCustomCSS () { async _loadCustomCSS () {

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

Loading…
Cancel
Save