Append [DEV] to window title in dev

This commit is contained in:
Gregory Schier
2024-08-09 15:35:21 -07:00
parent d280df4a0b
commit d5b0b5481c
2 changed files with 11 additions and 12 deletions

View File

@@ -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() };
}

View File

@@ -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]);
}