[UI > Settings] Fix removing billing settings and potential memory leak
This commit is contained in:
parent
65d57a0f69
commit
a462b8e81e
2 changed files with 10 additions and 10 deletions
|
@ -4,8 +4,6 @@ import { showToast } from "@ui/toasts";
|
||||||
import logger from "@lib/logger";
|
import logger from "@lib/logger";
|
||||||
export let socket: WebSocket;
|
export let socket: WebSocket;
|
||||||
|
|
||||||
let iLoveBundlers = eval;
|
|
||||||
|
|
||||||
export function connectToDebugger(url: string) {
|
export function connectToDebugger(url: string) {
|
||||||
if (socket !== undefined && socket.readyState !== WebSocket.CLOSED) {
|
if (socket !== undefined && socket.readyState !== WebSocket.CLOSED) {
|
||||||
socket.close();
|
socket.close();
|
||||||
|
@ -22,7 +20,7 @@ export function connectToDebugger(url: string) {
|
||||||
|
|
||||||
socket.addEventListener("message", (message: any) => {
|
socket.addEventListener("message", (message: any) => {
|
||||||
try {
|
try {
|
||||||
iLoveBundlers(message.data);
|
(0, eval)(message.data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import AssetBrowser from "@ui/settings/pages/AssetBrowser";
|
||||||
|
|
||||||
const screensModule = findByDisplayName("getScreens", false);
|
const screensModule = findByDisplayName("getScreens", false);
|
||||||
const settingsModule = findByDisplayName("UserSettingsOverviewWrapper", false);
|
const settingsModule = findByDisplayName("UserSettingsOverviewWrapper", false);
|
||||||
let settingsInjected = false;
|
let prevPatches: Function[] = [];
|
||||||
|
|
||||||
export default function initSettings() {
|
export default function initSettings() {
|
||||||
after("default", screensModule, (args, existingScreens) => {
|
after("default", screensModule, (args, existingScreens) => {
|
||||||
|
@ -31,19 +31,21 @@ export default function initSettings() {
|
||||||
});
|
});
|
||||||
|
|
||||||
after("default", settingsModule, (args, ret) => {
|
after("default", settingsModule, (args, ret) => {
|
||||||
|
for (let p of prevPatches) p();
|
||||||
|
prevPatches = [];
|
||||||
|
|
||||||
const Overview = findInReactTree(ret.props.children, i => i.type && i.type.name === "UserSettingsOverview");
|
const Overview = findInReactTree(ret.props.children, i => i.type && i.type.name === "UserSettingsOverview");
|
||||||
|
|
||||||
// Upload logs button gone
|
// Upload logs button gone
|
||||||
after("renderSupportAndAcknowledgements", Overview.type.prototype, (args, { props: { children } }) => {
|
prevPatches.push(after("renderSupportAndAcknowledgements", Overview.type.prototype, (args, { props: { children } }) => {
|
||||||
const index = children.findIndex((c: any) => c?.type?.name === "UploadLogsButton");
|
const index = children.findIndex((c: any) => c?.type?.name === "UploadLogsButton");
|
||||||
if (index !== -1) children.splice(index, 1);
|
if (index !== -1) children.splice(index, 1);
|
||||||
});
|
}));
|
||||||
|
|
||||||
after("render", Overview.type.prototype, (args, { props: { children } }) => {
|
prevPatches.push(after("render", Overview.type.prototype, (args, { props: { children } }) => {
|
||||||
const titles = [i18n.Messages["BILLING_SETTINGS"], i18n.Messages["PREMIUM_SETTINGS"]];
|
const titles = [i18n.Messages["BILLING_SETTINGS"], i18n.Messages["PREMIUM_SETTINGS"]];
|
||||||
const index = children.findIndex((c: any) => titles.includes(c.props.title));
|
const index = children.findIndex((c: any) => titles.includes(c.props.title));
|
||||||
children.splice(index === -1 ? 4 : index, settingsInjected ? 1 : 0, <SettingsSection navigation={Overview.props.navigation} />);
|
children.splice(index === -1 ? 4 : index, 0, <SettingsSection navigation={Overview.props.navigation} />);
|
||||||
if (!settingsInjected) settingsInjected = true;
|
}));
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
Loading…
Reference in a new issue