From 807c38306e6092bdc341bc94ee01bcc984379a8c Mon Sep 17 00:00:00 2001 From: Sean Boult <996134+Hacksore@users.noreply.github.com> Date: Mon, 6 Nov 2023 08:30:47 -0600 Subject: [PATCH] Remove invalidate shadows --- src-tauri/Cargo.lock | 2 +- src/App.tsx | 10 +++------- src/rpc/manager.ts | 17 ++++------------- src/use-border.ts | 2 -- src/utils.ts | 10 ---------- 5 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 src/utils.ts diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 2bb4425e..1cf282d3 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1963,7 +1963,7 @@ dependencies = [ ] [[package]] -name = "overlayed-rust-test" +name = "overlayed" version = "0.0.0" dependencies = [ "cocoa 0.25.0", diff --git a/src/App.tsx b/src/App.tsx index bb6a7a0e..e2df4cc8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,20 +1,18 @@ import socket from "./rpc/manager"; import { useEffect } from "react"; import { appWindow } from "@tauri-apps/api/window"; -import { Routes, Route, useNavigate, useLocation } from "react-router-dom"; +import { Routes, Route, useNavigate } from "react-router-dom"; import { Main } from "./views/main"; import { Channel } from "./views/channel"; import { Settings } from "./views/settings"; import { Error } from "./views/error"; import { NavBar } from "./components/nav-bar"; -import { invalidateWindowShadows } from "./utils"; import { useClickthrough } from "./use-clickthrough"; import { useBorder } from "./use-border"; function App() { const navigate = useNavigate(); - const location = useLocation(); const { clickthrough } = useClickthrough(); const { mouseInViewport } = useBorder(); @@ -22,13 +20,11 @@ function App() { useEffect(() => { console.log("APP: calling socket init"); socket.init(navigate); + + // TODO: maybe we set this in rust / config appWindow.setAlwaysOnTop(true); }, []); - useEffect(() => { - invalidateWindowShadows(); - }, [location]); - const border = !clickthrough && mouseInViewport ? "hover:border-blue-500" diff --git a/src/rpc/manager.ts b/src/rpc/manager.ts index 5ec0118b..7d498e0c 100644 --- a/src/rpc/manager.ts +++ b/src/rpc/manager.ts @@ -5,7 +5,6 @@ import * as uuid from "uuid"; import WebSocket, { Message } from "tauri-plugin-websocket-api"; import { AppActions, AppState, useAppStore as appStore } from "../store"; import type { NavigateFunction } from "react-router-dom"; -import { invalidateWindowShadows } from "../utils"; interface TokenResponse { access_token: string; @@ -48,7 +47,7 @@ interface DiscordPayload { cmd: `${RPCCommand}`; // TODO: how do i type this properly? args?: any; - data?: any, + data?: any; evt?: `${RPCEvent}` | null; nonce?: string; } @@ -97,7 +96,7 @@ class SocketManager { this.send({ args: { client_id: STREAM_KIT_APP_ID, - scopes: ["rpc"], + scopes: ["rpc", "identify"], }, cmd: RPCCommand.AUTHORIZE, }); @@ -138,20 +137,14 @@ class SocketManager { } this.store.removeUser(payload.data.user.id); - - await invalidateWindowShadows(); } if (payload.evt === RPCEvent.VOICE_STATE_CREATE) { this.store.addUser(payload.data); - - await invalidateWindowShadows(); } if (payload.evt === RPCEvent.VOICE_STATE_UPDATE) { this.store.updateUser(payload.data); - - await invalidateWindowShadows(); } // VOICE_CHANNEL_SELECT sent when the client joins a voice channel @@ -166,8 +159,6 @@ class SocketManager { // after unsub we clear the channel this.store.setCurrentChannel(null); - - await invalidateWindowShadows(); } // try to find the user @@ -187,7 +178,7 @@ class SocketManager { // we got a token back from discord let's fetch an access token if (payload.cmd === RPCCommand.AUTHORIZE) { const { code } = payload.data; - const res = await fetch(`${STREAMKIT_URL}/overlay/token`, { + const res = await fetch < TokenResponse > (`${STREAMKIT_URL}/overlay/token`, { method: "POST", body: Body.json({ code }), }); @@ -253,7 +244,7 @@ class SocketManager { this.requestUserChannel(); } - // console.log(payload); + console.log(payload); } /** diff --git a/src/use-border.ts b/src/use-border.ts index 8f6238e6..44575be5 100644 --- a/src/use-border.ts +++ b/src/use-border.ts @@ -6,8 +6,6 @@ export const useBorder = () => { const [mousePos, setMousePos] = useState({ x: 0, y: 0 }); useEffect(() => { - console.log("running useBorder effect"); - const mouseMoveFn = (event: MouseEvent) => { setMousePos({ x: event.clientX, y: event.clientY }); }; diff --git a/src/utils.ts b/src/utils.ts deleted file mode 100644 index 602e5333..00000000 --- a/src/utils.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { LogicalSize, appWindow } from "@tauri-apps/api/window"; - -// HACK: this fixes https://github.com/tauri-apps/tauri/issues/4243 -/** This will move the window 1px and then back to invalidate the window shadows */ -export const invalidateWindowShadows = async () => { - const oldSize = await appWindow.outerSize(); - const newSize = new LogicalSize(oldSize.width, oldSize.height + 1); - await appWindow.setSize(newSize); - await appWindow.setSize(oldSize); -};