From 0147906ce9409963bb48efeecc451cc1c7146ebe Mon Sep 17 00:00:00 2001
From: Sean Boult <996134+Hacksore@users.noreply.github.com>
Date: Thu, 9 Nov 2023 20:55:21 -0600
Subject: [PATCH] Settings page updates
---
package.json | 1 +
pnpm-lock.yaml | 14 +++++
src-tauri/Cargo.lock | 100 ++++++++++++++++++++++++++++++-----
src-tauri/Cargo.toml | 2 +-
src-tauri/src/main.rs | 3 +-
src-tauri/tauri.conf.json | 17 ++++--
src/App.tsx | 5 +-
src/components/nav-bar.tsx | 47 +++++-----------
src/components/ui/button.tsx | 47 ++++++++++++++++
src/store.ts | 2 +-
src/use-paths.ts | 38 ++++---------
src/views/channel.tsx | 5 +-
src/views/error.tsx | 5 +-
src/views/main.tsx | 5 +-
src/views/settings.tsx | 62 ++++++++++++++++++----
15 files changed, 256 insertions(+), 97 deletions(-)
create mode 100644 src/components/ui/button.tsx
diff --git a/package.json b/package.json
index 908d446a..939408a9 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
"@tanstack/react-router": "0.0.1-beta.204",
"@tauri-apps/api": "^1.5.0",
"@uidotdev/usehooks": "^2.4.1",
+ "class-variance-authority": "^0.7.0",
"events": "^3.3.0",
"immer": "^10.0.3",
"lucide-react": "^0.292.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3b045e94..228fa9e9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -17,6 +17,9 @@ dependencies:
'@uidotdev/usehooks':
specifier: ^2.4.1
version: 2.4.1(react-dom@18.2.0)(react@18.2.0)
+ class-variance-authority:
+ specifier: ^0.7.0
+ version: 0.7.0
events:
specifier: ^3.3.0
version: 3.3.0
@@ -939,6 +942,17 @@ packages:
fsevents: 2.3.3
dev: true
+ /class-variance-authority@0.7.0:
+ resolution: {integrity: sha512-jFI8IQw4hczaL4ALINxqLEXQbWcNjoSkloa4IaufXCJr6QawJyw7tuRysRsrE8w2p/4gGaxKIt/hX3qz/IbD1A==}
+ dependencies:
+ clsx: 2.0.0
+ dev: false
+
+ /clsx@2.0.0:
+ resolution: {integrity: sha512-rQ1+kcj+ttHG0MKVGBUXwayCCF1oh39BF5COIpRzuCEv8Mwjv0XucrI2ExNTOn9IlLifGClWQcU9BrZORvtw6Q==}
+ engines: {node: '>=6'}
+ dev: false
+
/color-convert@1.9.3:
resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==}
dependencies:
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 2110d561..710a6b2a 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -679,7 +679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
dependencies = [
"libc",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -716,7 +716,7 @@ dependencies = [
"cfg-if",
"libc",
"redox_syscall 0.3.5",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -1752,7 +1752,7 @@ checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0"
dependencies = [
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -1927,6 +1927,16 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
+[[package]]
+name = "open"
+version = "3.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2078c0039e6a54a0c42c28faa984e115fb4c2d5bf2208f77d1961002df8576f8"
+dependencies = [
+ "pathdiff",
+ "windows-sys 0.42.0",
+]
+
[[package]]
name = "openssl"
version = "0.10.57"
@@ -2041,6 +2051,12 @@ dependencies = [
"windows-targets",
]
+[[package]]
+name = "pathdiff"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
+
[[package]]
name = "percent-encoding"
version = "2.3.0"
@@ -2519,7 +2535,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -2555,7 +2571,7 @@ version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88"
dependencies = [
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -2830,7 +2846,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
dependencies = [
"libc",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -3076,9 +3092,11 @@ dependencies = [
"ignore",
"objc",
"once_cell",
+ "open",
"percent-encoding",
"rand 0.8.5",
"raw-window-handle",
+ "regex",
"reqwest",
"semver",
"serde",
@@ -3134,6 +3152,7 @@ dependencies = [
"png",
"proc-macro2",
"quote",
+ "regex",
"semver",
"serde",
"serde_json",
@@ -3280,7 +3299,7 @@ dependencies = [
"fastrand",
"redox_syscall 0.4.1",
"rustix",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -3390,7 +3409,7 @@ dependencies = [
"signal-hook-registry",
"socket2 0.5.5",
"tokio-macros",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -4016,6 +4035,21 @@ version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ee5e275231f07c6e240d14f34e1b635bf1faa1c76c57cfd59a5cdb9848e4278"
+[[package]]
+name = "windows-sys"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
+dependencies = [
+ "windows_aarch64_gnullvm 0.42.2",
+ "windows_aarch64_msvc 0.42.2",
+ "windows_i686_gnu 0.42.2",
+ "windows_i686_msvc 0.42.2",
+ "windows_x86_64_gnu 0.42.2",
+ "windows_x86_64_gnullvm 0.42.2",
+ "windows_x86_64_msvc 0.42.2",
+]
+
[[package]]
name = "windows-sys"
version = "0.48.0"
@@ -4031,12 +4065,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
- "windows_aarch64_gnullvm",
+ "windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
- "windows_x86_64_gnullvm",
+ "windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
]
@@ -4046,6 +4080,12 @@ version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f838de2fe15fe6bac988e74b798f26499a8b21a9d97edec321e79b28d1d7f597"
+[[package]]
+name = "windows_aarch64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
+
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
@@ -4058,6 +4098,12 @@ version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2"
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
+
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
@@ -4070,6 +4116,12 @@ version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b"
+[[package]]
+name = "windows_i686_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
+
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
@@ -4082,6 +4134,12 @@ version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106"
+[[package]]
+name = "windows_i686_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
+
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
@@ -4094,12 +4152,24 @@ version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65"
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
+
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
+
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
@@ -4112,6 +4182,12 @@ version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809"
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
+
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
@@ -4134,7 +4210,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
dependencies = [
"cfg-if",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
@@ -4144,7 +4220,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "937f3df7948156640f46aacef17a70db0de5917bda9c92b0f751f3a955b588fc"
dependencies = [
"cfg-if",
- "windows-sys",
+ "windows-sys 0.48.0",
]
[[package]]
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 44384cb9..4af95313 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -13,7 +13,7 @@ edition = "2021"
tauri-build = { version = "1.5", features = [] }
[dependencies]
-tauri = { version = "1.5", features = [ "path-all", "fs-read-file", "fs-exists", "fs-write-file", "system-tray", "window-set-size", "window-set-always-on-top", "window-start-dragging", "macos-private-api", "devtools", "http-all"] }
+tauri = { version = "1.5", features = [ "shell-open", "path-all", "fs-read-file", "fs-exists", "fs-write-file", "system-tray", "window-set-size", "window-set-always-on-top", "window-start-dragging", "macos-private-api", "devtools", "http-all"] }
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1", features = ["full"] } # Required for asynchronous operations
tauri-plugin-websocket = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 79d29787..7391fdce 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -10,7 +10,7 @@ extern crate objc;
use tauri::{
generate_handler, CustomMenuItem, Manager, RunEvent, State, SystemTray, SystemTrayEvent,
- SystemTrayMenu, Window,
+ SystemTrayMenu, Window, ActivationPolicy,
};
#[cfg(target_os = "macos")]
@@ -86,6 +86,7 @@ fn main() {
#[cfg(target_os = "macos")]
window.set_transparent_titlebar(true, true);
+ app.set_activation_policy(ActivationPolicy::Accessory);
// Open dev tools only when in dev mode
#[cfg(debug_assertions)]
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 142a44d3..0a9c0e58 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -17,8 +17,13 @@
},
"allowlist": {
"all": false,
+ "shell": {
+ "open": ".*"
+ },
"fs": {
- "scope": ["$APPDATA/*"],
+ "scope": [
+ "$APPDATA/*"
+ ],
"readFile": true,
"writeFile": true,
"exists": true
@@ -26,7 +31,9 @@
"http": {
"all": true,
"request": true,
- "scope": ["https://streamkit.discord.com/overlay/token"]
+ "scope": [
+ "https://streamkit.discord.com/overlay/token"
+ ]
},
"path": {
"all": true
@@ -41,7 +48,11 @@
"active": true,
"targets": "all",
"identifier": "com.hacksore.overlayed",
- "icon": ["icons/icon.icns", "icons/icon.ico", "icons/icon.png"]
+ "icon": [
+ "icons/icon.icns",
+ "icons/icon.ico",
+ "icons/icon.png"
+ ]
},
"security": {
"csp": null
diff --git a/src/App.tsx b/src/App.tsx
index a61c47ac..8455186e 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,5 +1,5 @@
import { useSocket } from "./rpc/manager";
-import { Routes, Route } from "react-router-dom";
+import { Routes, Route, useLocation } from "react-router-dom";
import { Main } from "./views/main";
import { Channel } from "./views/channel";
@@ -14,9 +14,10 @@ function App() {
const { clickthrough } = useClickthrough();
const { mouseInViewport } = useBorder();
+ const location = useLocation();
const border =
- !clickthrough && mouseInViewport
+ !clickthrough && mouseInViewport && location.pathname === "/channel"
? "hover:border-blue-500"
: "border-transparent";
diff --git a/src/components/nav-bar.tsx b/src/components/nav-bar.tsx
index d91d6584..6e1667ec 100644
--- a/src/components/nav-bar.tsx
+++ b/src/components/nav-bar.tsx
@@ -1,35 +1,13 @@
-import { useCallback } from "react";
import { Link, useLocation, useNavigate } from "react-router-dom";
-import { Settings, RefreshCcw, Home, Eye } from "lucide-react";
+import { Settings, RefreshCcw, EyeOff } from "lucide-react";
import { invoke } from "@tauri-apps/api";
import overlayedConfig from "../config";
+import { Button } from "./ui/button";
export const NavBar = ({ clickthrough }: { clickthrough: boolean }) => {
const location = useLocation();
const navigate = useNavigate();
- const getNavLink = useCallback(() => {
- if (["/channel", "/"].includes(location.pathname)) {
- return (
-
-
Request Prompt again
-{JSON.stringify({clickthrough, paths }, null, 2)}-
{JSON.stringify({ id: me?.id }, null, 2)}+