[Toasts] Implement
This commit is contained in:
parent
111720806c
commit
9f1fe6313d
3 changed files with 24 additions and 1 deletions
|
@ -1,4 +1,6 @@
|
|||
import { after } from "@lib/patcher";
|
||||
import { getAssetIDByName } from "@ui/assets";
|
||||
import { showToast } from "@ui/toasts";
|
||||
import logger from "@lib/logger";
|
||||
export let socket: WebSocket;
|
||||
|
||||
|
@ -9,8 +11,15 @@ export function connectToDebugWS(url: string) {
|
|||
socket.close();
|
||||
}
|
||||
|
||||
if (url === "") {
|
||||
showToast("Invalid debugger URL!", getAssetIDByName("Small"));
|
||||
return;
|
||||
}
|
||||
|
||||
socket = new WebSocket(`ws://${url}`);
|
||||
|
||||
socket.addEventListener("open", () => showToast("Connected to debugger.", getAssetIDByName("Check")));
|
||||
|
||||
socket.addEventListener("message", (message: any) => {
|
||||
try {
|
||||
iLoveBundlers(message.data);
|
||||
|
@ -18,6 +27,11 @@ export function connectToDebugWS(url: string) {
|
|||
console.error(e);
|
||||
}
|
||||
});
|
||||
|
||||
socket.addEventListener("error", (err: any) => {
|
||||
console.log(`Debugger error: ${err.message}`);
|
||||
showToast("An error occurred with the debugger connection!", getAssetIDByName("Small"));
|
||||
});
|
||||
}
|
||||
|
||||
export function patchLogHook() {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { findByProps } from "@metro/filters";
|
||||
import { find, findByProps } from "@metro/filters";
|
||||
|
||||
// Discord
|
||||
export const constants = findByProps("API_HOST");
|
||||
export const channels = findByProps("getVoiceChannelId");
|
||||
export const i18n = findByProps("Messages");
|
||||
export const toasts = find(m => m.open && m.close && !m.startDrag && !m.init && !m.openReplay && !m.setAlwaysOnTop);
|
||||
|
||||
// React
|
||||
export const React = findByProps("createElement") as typeof import("react");
|
||||
|
|
8
src/ui/toasts.ts
Normal file
8
src/ui/toasts.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
import { toasts } from "@metro/common";
|
||||
|
||||
export function showToast(content: string, asset: number) {
|
||||
return toasts.open({
|
||||
content: content,
|
||||
source: asset
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue