mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-21 00:49:17 +01:00
25 lines
1005 B
TypeScript
25 lines
1005 B
TypeScript
import { useEffect } from 'react';
|
||
import { fallbackRequestName } from '../lib/fallbackRequestName';
|
||
import { useActiveEnvironment } from './useActiveEnvironment';
|
||
import { useActiveRequest } from './useActiveRequest';
|
||
import { useActiveWorkspace } from './useActiveWorkspace';
|
||
|
||
export function useSyncWindowTitle() {
|
||
const activeRequest = useActiveRequest();
|
||
const activeWorkspace = useActiveWorkspace();
|
||
const activeEnvironment = useActiveEnvironment();
|
||
useEffect(() => {
|
||
let newTitle = activeWorkspace ? activeWorkspace.name : 'Yaak';
|
||
if (activeEnvironment) {
|
||
newTitle += ` [${activeEnvironment.name}]`;
|
||
}
|
||
if (activeRequest) {
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||
newTitle += ` – ${fallbackRequestName(activeRequest)}`;
|
||
}
|
||
|
||
// TODO: This resets the stoplight position so we can't use it yet
|
||
// invoke('cmd_set_title', { title: newTitle }).catch(console.error);
|
||
}, [activeEnvironment, activeRequest, activeWorkspace]);
|
||
}
|