1
1
mirror of https://github.com/neosubhamoy/pytubepp-helper.git synced 2026-02-04 11:22:22 +05:30

(feat): added app theme selection option in settings

This commit is contained in:
2025-02-23 22:25:58 +05:30
Verified
parent f1f7d78c4e
commit c17909d980
9 changed files with 740 additions and 13 deletions

View File

@@ -4,7 +4,7 @@ import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import { ThemeProvider } from "@/components/theme-provider";
import { WebSocketMessage } from "@/types";
import { Config, WebSocketMessage } from "@/types";
import { sendStreamInfo } from "@/lib/utils";
import { Toaster } from "@/components/ui/toaster";
import { TooltipProvider } from "@/components/ui/tooltip";
@@ -13,6 +13,7 @@ import { isPermissionGranted, requestPermission, sendNotification } from "@tauri
function App({ children }: { children: React.ReactNode }) {
const appWindow = getCurrentWebviewWindow()
const [appConfig, setAppConfig] = useState<Config | null>(null);
const [isAppUpdateChecked, setIsAppUpdateChecked] = useState(false);
// Prevent right click context menu in production
@@ -31,6 +32,16 @@ function App({ children }: { children: React.ReactNode }) {
appWindow.onCloseRequested(handleCloseRequested);
}, []);
useEffect(() => {
const getConfig = async () => {
const config: Config = await invoke("get_config");
if (config) {
setAppConfig(config);
}
}
getConfig().catch(console.error);
}, []);
useEffect(() => {
const unlisten = listen<WebSocketMessage>('websocket-message', (event) => {
if(event.payload.command === 'send-stream-info') {
@@ -86,7 +97,7 @@ function App({ children }: { children: React.ReactNode }) {
}, [])
return (
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
<ThemeProvider defaultTheme={appConfig?.theme || "system"} storageKey="vite-ui-theme">
<TooltipProvider delayDuration={1000}>
{children}
<Toaster />