aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/Notices.ts24
-rw-r--r--src/api/index.ts1
-rw-r--r--src/api/settings.ts6
3 files changed, 29 insertions, 2 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();
+}
diff --git a/src/api/index.ts b/src/api/index.ts
index 0633ee8..7d39b95 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -1 +1,2 @@
export * as MessageEvents from "./MessageEvents";
+export * as Notices from "./Notices";
diff --git a/src/api/settings.ts b/src/api/settings.ts
index 4ee94d3..17f3f12 100644
--- a/src/api/settings.ts
+++ b/src/api/settings.ts
@@ -4,6 +4,7 @@ import { React } from "../webpack/common";
import { mergeDefaults } from '../utils/misc';
interface Settings {
+ notifyAboutUpdates: boolean;
unsafeRequire: boolean;
useQuickCss: boolean;
plugins: {
@@ -15,10 +16,11 @@ interface Settings {
}
const DefaultSettings: Settings = {
+ notifyAboutUpdates: true,
unsafeRequire: false,
useQuickCss: true,
plugins: {}
-} as any;
+};
for (const plugin in plugins) {
DefaultSettings.plugins[plugin] = {
@@ -77,7 +79,7 @@ export const Settings = makeProxy(settings);
* @returns Settings
*/
export function useSettings() {
- const [, forceUpdate] = React.useReducer(x => ({}), {});
+ const [, forceUpdate] = React.useReducer(() => ({}), {});
React.useEffect(() => {
subscriptions.add(forceUpdate);