Skip to content

Commit

Permalink
Add settings and fix reload bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Hacksore committed Nov 15, 2023
1 parent 8c4ce65 commit aa48df0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 1 addition & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri + React + TS</title>
<title>overlayed</title>
</head>

<body>
Expand Down
6 changes: 6 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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")),
);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/use-clickthrough.ts
Original file line number Diff line number Diff line change
@@ -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<boolean>("toggle_clickthrough", (event) => {
setClickthrough(event.payload);
overlayedConfig.set("clickthrough", event.payload);
});

// This is so we can sync the state
invoke<boolean>("get_clickthrough").then((clickthrough) =>
setClickthrough(clickthrough)
);

return () => {
unlisten.then((f) => f());
};
Expand Down

0 comments on commit aa48df0

Please sign in to comment.