mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-28 12:23:31 +01:00
Titlebar fixes
This commit is contained in:
23
ts/hooks/useIsWindowActive.ts
Normal file
23
ts/hooks/useIsWindowActive.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export function useIsWindowActive(): boolean {
|
||||
const { activeWindowService } = window.SignalContext;
|
||||
const [isActive, setIsActive] = useState(activeWindowService.isActive());
|
||||
|
||||
useEffect(() => {
|
||||
const update = (newIsActive: boolean): void => {
|
||||
setIsActive(newIsActive);
|
||||
};
|
||||
|
||||
activeWindowService.registerForChange(update);
|
||||
|
||||
return () => {
|
||||
activeWindowService.unregisterForChange(update);
|
||||
};
|
||||
}, [activeWindowService]);
|
||||
|
||||
return isActive;
|
||||
}
|
||||
Reference in New Issue
Block a user