From 4c4477e79e674266f3f977f3618f7776e7578bb6 Mon Sep 17 00:00:00 2001
From: Paul <paulmakles@gmail.com>
Date: Tue, 3 Aug 2021 20:04:46 +0100
Subject: [PATCH] Add new native options.

---
 src/globals.d.ts                    |  5 ++--
 src/pages/settings/panes/Native.tsx | 36 +++++++++++++++++++++++++----
 2 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/src/globals.d.ts b/src/globals.d.ts
index b8e76fe..927d162 100644
--- a/src/globals.d.ts
+++ b/src/globals.d.ts
@@ -3,6 +3,8 @@ type Build = "stable" | "nightly" | "dev";
 type NativeConfig = {
     frame: boolean;
     build: Build;
+    discordRPC: boolean;
+    hardwareAcceleration: boolean;
 };
 
 declare interface Window {
@@ -16,8 +18,7 @@ declare interface Window {
         relaunch();
 
         getConfig(): NativeConfig;
-        setFrame(frame: boolean);
-        setBuild(build: Build);
+        set(key: keyof NativeConfig, value: any);
 
         getAutoStart(): Promise<boolean>;
         enableAutoStart(): Promise<void>;
diff --git a/src/pages/settings/panes/Native.tsx b/src/pages/settings/panes/Native.tsx
index cab36b8..6d043b3 100644
--- a/src/pages/settings/panes/Native.tsx
+++ b/src/pages/settings/panes/Native.tsx
@@ -40,10 +40,26 @@ export function Native(props: Props) {
                 description="Launch Revolt when you log into your computer.">
                 Start with computer
             </Checkbox>
+            <Checkbox
+                checked={config.hardwareAcceleration}
+                onChange={async (hardwareAcceleration) => {
+                    window.native.set(
+                        "hardwareAcceleration",
+                        hardwareAcceleration,
+                    );
+                    setHintRelaunch(true);
+                    setConfig({
+                        ...config,
+                        hardwareAcceleration,
+                    });
+                }}
+                description="Use the GPU to render the app, disable if you run into visual issues.">
+                Hardware Acceleration
+            </Checkbox>
             <Checkbox
                 checked={!config.frame}
                 onChange={(frame) => {
-                    window.native.setFrame(!frame);
+                    window.native.set("frame", !frame);
                     setHintRelaunch(true);
                     setConfig({
                         ...config,
@@ -53,11 +69,23 @@ export function Native(props: Props) {
                 description={<>Let Revolt use its own window frame.</>}>
                 Custom window frame
             </Checkbox>
+            <Checkbox
+                checked={config.discordRPC}
+                onChange={(discordRPC) => {
+                    window.native.set("discordRPC", discordRPC);
+                    setConfig({
+                        ...config,
+                        discordRPC,
+                    });
+                }}
+                description={<>Rep Revolt on your Discord status.</>}>
+                Discord RPC
+            </Checkbox>
             <Checkbox
                 checked={config.build === "nightly"}
                 onChange={(nightly) => {
                     const build = nightly ? "nightly" : "stable";
-                    window.native.setBuild(build);
+                    window.native.set("build", build);
                     setHintReload(true);
                     setConfig({
                         ...config,
@@ -90,7 +118,7 @@ export function Native(props: Props) {
                         contrast
                         compact
                         onClick={() => {
-                            window.native.setBuild("stable");
+                            window.native.set("build", "stable");
                             window.native.reload();
                         }}>
                         Exit Development Mode
@@ -123,7 +151,7 @@ export function Native(props: Props) {
                             compact
                             disabled={!confirmDev}
                             onClick={() => {
-                                window.native.setBuild("dev");
+                                window.native.set("build", "dev");
                                 window.native.reload();
                             }}>
                             Enter Development Mode
-- 
GitLab