diff --git a/renderer/src/api/Popups.js b/renderer/src/api/Popups.js index 00b16380..46be33b5 100644 --- a/renderer/src/api/Popups.js +++ b/renderer/src/api/Popups.js @@ -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 + : ( +
+ {children} +
+ ) } ); }); + return new Promise(() => { const popupModule = getModule('setAlwaysOnTop', 'open'); popupModule.open(`DISCORD_${popup.popupId}`, key => { return ( - - - {popup.render && !popup.url && } - - + + {popup.render && !popup.url && } + ); }, options); }); @@ -141,10 +146,4 @@ export default class Popups extends API { return this.error(err); } } - - stop () { - this.closeAllPopups(); - this.removeAllListeners(); - delete vizality.api.popups; - } } diff --git a/renderer/src/builtins/quick-code/index.js b/renderer/src/builtins/quick-code/index.js index 9f8cd8bf..59bb6b60 100644 --- a/renderer/src/builtins/quick-code/index.js +++ b/renderer/src/builtins/quick-code/index.js @@ -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 => - }); + try { + vizality.api.popups.openPopup({ + popupId: 'VIZALITY_CUSTOM_CSS', + title: 'Quick Code - CSS', + titlebarType: 'WINDOWS', + render: props => + }); + } catch (err) { + this.error(err); + } } async _loadCustomCSS () { diff --git a/renderer/src/modules/components/PopupWindow.jsx b/renderer/src/modules/components/PopupWindow.jsx index 1d831325..2cd5060a 100644 --- a/renderer/src/modules/components/PopupWindow.jsx +++ b/renderer/src/modules/components/PopupWindow.jsx @@ -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 () {