mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-25 18:16:32 +00:00
* refactor: streamline codebase, unify duplicated modules, and consolidate tests * fix(test): batch discovered test files into Windows-safe command lines
33 lines
779 B
TypeScript
33 lines
779 B
TypeScript
import { useSyncExternalStore } from 'react';
|
|
import { createListenerRegistry } from './createExternalStore';
|
|
|
|
let suppressDepth = 0;
|
|
const registry = createListenerRegistry();
|
|
|
|
export const terminalLayoutSuppressStore = {
|
|
getActive: () => suppressDepth > 0,
|
|
|
|
subscribe: registry.subscribe,
|
|
|
|
begin: () => {
|
|
suppressDepth += 1;
|
|
registry.scheduleNotify();
|
|
},
|
|
|
|
end: () => {
|
|
const wasActive = suppressDepth > 0;
|
|
suppressDepth = Math.max(0, suppressDepth - 1);
|
|
if (wasActive) {
|
|
registry.scheduleNotify();
|
|
}
|
|
},
|
|
};
|
|
|
|
export function useTerminalLayoutSuppressActive(): boolean {
|
|
return useSyncExternalStore(
|
|
terminalLayoutSuppressStore.subscribe,
|
|
terminalLayoutSuppressStore.getActive,
|
|
terminalLayoutSuppressStore.getActive,
|
|
);
|
|
}
|