Add new native options.

This commit is contained in:
Paul 2021-08-03 20:04:46 +01:00
parent f4b04635de
commit 4c4477e79e
2 changed files with 35 additions and 6 deletions

5
src/globals.d.ts vendored
View file

@ -3,6 +3,8 @@ type Build = "stable" | "nightly" | "dev";
type NativeConfig = { type NativeConfig = {
frame: boolean; frame: boolean;
build: Build; build: Build;
discordRPC: boolean;
hardwareAcceleration: boolean;
}; };
declare interface Window { declare interface Window {
@ -16,8 +18,7 @@ declare interface Window {
relaunch(); relaunch();
getConfig(): NativeConfig; getConfig(): NativeConfig;
setFrame(frame: boolean); set(key: keyof NativeConfig, value: any);
setBuild(build: Build);
getAutoStart(): Promise<boolean>; getAutoStart(): Promise<boolean>;
enableAutoStart(): Promise<void>; enableAutoStart(): Promise<void>;

View file

@ -40,10 +40,26 @@ export function Native(props: Props) {
description="Launch Revolt when you log into your computer."> description="Launch Revolt when you log into your computer.">
Start with computer Start with computer
</Checkbox> </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 <Checkbox
checked={!config.frame} checked={!config.frame}
onChange={(frame) => { onChange={(frame) => {
window.native.setFrame(!frame); window.native.set("frame", !frame);
setHintRelaunch(true); setHintRelaunch(true);
setConfig({ setConfig({
...config, ...config,
@ -53,11 +69,23 @@ export function Native(props: Props) {
description={<>Let Revolt use its own window frame.</>}> description={<>Let Revolt use its own window frame.</>}>
Custom window frame Custom window frame
</Checkbox> </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 <Checkbox
checked={config.build === "nightly"} checked={config.build === "nightly"}
onChange={(nightly) => { onChange={(nightly) => {
const build = nightly ? "nightly" : "stable"; const build = nightly ? "nightly" : "stable";
window.native.setBuild(build); window.native.set("build", build);
setHintReload(true); setHintReload(true);
setConfig({ setConfig({
...config, ...config,
@ -90,7 +118,7 @@ export function Native(props: Props) {
contrast contrast
compact compact
onClick={() => { onClick={() => {
window.native.setBuild("stable"); window.native.set("build", "stable");
window.native.reload(); window.native.reload();
}}> }}>
Exit Development Mode Exit Development Mode
@ -123,7 +151,7 @@ export function Native(props: Props) {
compact compact
disabled={!confirmDev} disabled={!confirmDev}
onClick={() => { onClick={() => {
window.native.setBuild("dev"); window.native.set("build", "dev");
window.native.reload(); window.native.reload();
}}> }}>
Enter Development Mode Enter Development Mode