mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 20:00:29 +01:00
Append [DEV] to window title in dev
This commit is contained in:
@@ -1,12 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { OsType } from '@tauri-apps/plugin-os';
|
||||
import { type } from '@tauri-apps/plugin-os';
|
||||
|
||||
export function useOsInfo() {
|
||||
return useQuery<{ osType: OsType }>({
|
||||
queryKey: ['platform'],
|
||||
queryFn: async () => {
|
||||
return { osType: await type() };
|
||||
},
|
||||
}).data;
|
||||
return { osType: type() };
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { fallbackRequestName } from '../lib/fallbackRequestName';
|
||||
import { useActiveEnvironment } from './useActiveEnvironment';
|
||||
import { useActiveRequest } from './useActiveRequest';
|
||||
import { useActiveWorkspace } from './useActiveWorkspace';
|
||||
import { useAppInfo } from './useAppInfo';
|
||||
import { useOsInfo } from './useOsInfo';
|
||||
import { emit } from '@tauri-apps/api/event';
|
||||
|
||||
@@ -12,9 +13,10 @@ export function useSyncWorkspaceRequestTitle() {
|
||||
const activeWorkspace = useActiveWorkspace();
|
||||
const activeEnvironment = useActiveEnvironment();
|
||||
const osInfo = useOsInfo();
|
||||
const appInfo = useAppInfo();
|
||||
|
||||
useEffect(() => {
|
||||
if (osInfo?.osType == null) {
|
||||
if (osInfo.osType == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -24,15 +26,19 @@ export function useSyncWorkspaceRequestTitle() {
|
||||
}
|
||||
if (activeRequest) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
newTitle += ` – ${fallbackRequestName(activeRequest)}`;
|
||||
newTitle += ` › ${fallbackRequestName(activeRequest)}`;
|
||||
}
|
||||
|
||||
if (appInfo?.isDev) {
|
||||
newTitle = `[DEV] ${newTitle}`;
|
||||
}
|
||||
|
||||
// TODO: This resets the stoplight position so we can't use it on macOS yet. So we send
|
||||
// a custom command instead
|
||||
if (osInfo?.osType !== 'macos') {
|
||||
if (osInfo.osType !== 'macos') {
|
||||
getCurrentWebviewWindow().setTitle(newTitle).catch(console.error);
|
||||
} else {
|
||||
emit('yaak_title_changed', newTitle).catch(console.error);
|
||||
}
|
||||
}, [activeEnvironment, activeRequest, activeWorkspace, osInfo?.osType]);
|
||||
}, [activeEnvironment, activeRequest, activeWorkspace, appInfo?.isDev, osInfo.osType]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user