Append [DEV] to window title in dev

This commit is contained in:
Gregory Schier
2024-08-09 15:35:21 -07:00
parent 673f2920a1
commit e461851f6f
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'; import { type } from '@tauri-apps/plugin-os';
export function useOsInfo() { export function useOsInfo() {
return useQuery<{ osType: OsType }>({ return { osType: type() };
queryKey: ['platform'],
queryFn: async () => {
return { osType: await type() };
},
}).data;
} }

View File

@@ -4,6 +4,7 @@ import { fallbackRequestName } from '../lib/fallbackRequestName';
import { useActiveEnvironment } from './useActiveEnvironment'; import { useActiveEnvironment } from './useActiveEnvironment';
import { useActiveRequest } from './useActiveRequest'; import { useActiveRequest } from './useActiveRequest';
import { useActiveWorkspace } from './useActiveWorkspace'; import { useActiveWorkspace } from './useActiveWorkspace';
import { useAppInfo } from './useAppInfo';
import { useOsInfo } from './useOsInfo'; import { useOsInfo } from './useOsInfo';
import { emit } from '@tauri-apps/api/event'; import { emit } from '@tauri-apps/api/event';
@@ -12,9 +13,10 @@ export function useSyncWorkspaceRequestTitle() {
const activeWorkspace = useActiveWorkspace(); const activeWorkspace = useActiveWorkspace();
const activeEnvironment = useActiveEnvironment(); const activeEnvironment = useActiveEnvironment();
const osInfo = useOsInfo(); const osInfo = useOsInfo();
const appInfo = useAppInfo();
useEffect(() => { useEffect(() => {
if (osInfo?.osType == null) { if (osInfo.osType == null) {
return; return;
} }
@@ -24,15 +26,19 @@ export function useSyncWorkspaceRequestTitle() {
} }
if (activeRequest) { if (activeRequest) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars // 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 // TODO: This resets the stoplight position so we can't use it on macOS yet. So we send
// a custom command instead // a custom command instead
if (osInfo?.osType !== 'macos') { if (osInfo.osType !== 'macos') {
getCurrentWebviewWindow().setTitle(newTitle).catch(console.error); getCurrentWebviewWindow().setTitle(newTitle).catch(console.error);
} else { } else {
emit('yaak_title_changed', newTitle).catch(console.error); emit('yaak_title_changed', newTitle).catch(console.error);
} }
}, [activeEnvironment, activeRequest, activeWorkspace, osInfo?.osType]); }, [activeEnvironment, activeRequest, activeWorkspace, appInfo?.isDev, osInfo.osType]);
} }