mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-25 10:18:31 +02: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';
|
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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user