From aa48df005c9b5c90bfe85833610ad5423d521159 Mon Sep 17 00:00:00 2001
From: Sean Boult <996134+Hacksore@users.noreply.github.com>
Date: Tue, 14 Nov 2023 21:45:45 -0600
Subject: [PATCH] Add settings and fix reload bug
---
index.html | 3 +--
src-tauri/src/main.rs | 6 ++++++
src/rpc/manager.ts | 2 +-
src/use-clickthrough.ts | 7 +++++++
4 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/index.html b/index.html
index 03abf55f..0f83c981 100644
--- a/index.html
+++ b/index.html
@@ -2,9 +2,8 @@
-
- Tauri + React + TS
+ overlayed
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 65a66f57..3c2ae4ad 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -33,6 +33,7 @@ const TOGGLE_CLICKTHROUGH: &str = "toggle_clickthrough";
const TRAY_TOGGLE_CLICKTHROUGH: &str = "toggle_clickthrough";
const TRAY_SHOW_APP: &str = "show_app";
const TRAY_RELOAD: &str = "reload";
+const TRAY_SETTINGS: &str = "show_settings";
const TRAY_OPEN_DEVTOOLS: &str = "open_devtools";
const TRAY_QUIT: &str = "quit";
@@ -84,6 +85,7 @@ fn main() {
.add_item(CustomMenuItem::new(TRAY_SHOW_APP, "Show Overlayed"))
.add_item(CustomMenuItem::new(TRAY_RELOAD, "Reload App"))
.add_item(CustomMenuItem::new(TRAY_OPEN_DEVTOOLS, "Open Devtools"))
+ .add_item(CustomMenuItem::new(TRAY_SETTINGS, "Settings"))
.add_native_item(tauri::SystemTrayMenuItem::Separator)
.add_item(CustomMenuItem::new(TRAY_QUIT, "Quit")),
);
@@ -132,6 +134,10 @@ fn main() {
let window = app.get_window(MAIN_WINDOW_NAME).unwrap();
window.eval("window.location.reload();").unwrap();
}
+ TRAY_SETTINGS => {
+ let window = app.get_window(MAIN_WINDOW_NAME).unwrap();
+ window.eval("window.location.href = 'http://localhost:1420/#/settings'").unwrap();
+ }
TRAY_OPEN_DEVTOOLS => {
let window = app.get_window(MAIN_WINDOW_NAME).unwrap();
window.open_devtools();
diff --git a/src/rpc/manager.ts b/src/rpc/manager.ts
index c72edd8c..6be90f17 100644
--- a/src/rpc/manager.ts
+++ b/src/rpc/manager.ts
@@ -144,7 +144,7 @@ class SocketManager {
const payload: DiscordPayload = JSON.parse(event.data);
- console.log(payload);
+ // console.log(payload);
// either the token is good and valid and we can login otherwise prompt them approve
if (payload.evt === RPCEvent.READY) {
const acessToken = this.tokenStore?.accessToken;
diff --git a/src/use-clickthrough.ts b/src/use-clickthrough.ts
index d823ae7a..ebd31437 100644
--- a/src/use-clickthrough.ts
+++ b/src/use-clickthrough.ts
@@ -1,15 +1,22 @@
import { useEffect, useState } from "react";
import { listen } from "@tauri-apps/api/event";
import overlayedConfig from "./config";
+import { invoke } from "@tauri-apps/api";
export const useClickthrough = () => {
const [clickthrough, setClickthrough] = useState(false);
useEffect(() => {
+ // sub if it changes from outside of tauri
const unlisten = listen("toggle_clickthrough", (event) => {
setClickthrough(event.payload);
overlayedConfig.set("clickthrough", event.payload);
});
+ // This is so we can sync the state
+ invoke("get_clickthrough").then((clickthrough) =>
+ setClickthrough(clickthrough)
+ );
+
return () => {
unlisten.then((f) => f());
};