aboutsummaryrefslogtreecommitdiff
path: root/src/api/Notices.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/Notices.ts')
-rw-r--r--src/api/Notices.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/api/Notices.ts b/src/api/Notices.ts
new file mode 100644
index 0000000..66cae0e
--- /dev/null
+++ b/src/api/Notices.ts
@@ -0,0 +1,24 @@
+import { waitFor } from "../webpack";
+
+let NoticesModule: any;
+waitFor(m => m.show && m.dismiss && !m.suppressAll, m => NoticesModule = m);
+
+export const noticesQueue = [] as any[];
+export let currentNotice: any = null;
+
+export function popNotice() {
+ NoticesModule.dismiss();
+}
+
+export function nextNotice() {
+ currentNotice = noticesQueue.shift();
+
+ if (currentNotice) {
+ NoticesModule.show(...currentNotice, "VencordNotice");
+ }
+}
+
+export function showNotice(message: string, buttonText: string, onOkClick: () => void) {
+ noticesQueue.push(["GENERIC", message, buttonText, onOkClick]);
+ if (!currentNotice) nextNotice();
+}