Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp
662 B
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-or-later

import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {useEffect, useRef} from 'react';

export function useChannelPanelVisibility(channelId: string | null, visible: boolean): void {
	const previousVisibilityRef = useRef({channelId, visible});
	useEffect(() => {
		const previousVisibility = previousVisibilityRef.current;
		previousVisibilityRef.current = {channelId, visible};
		if (!channelId) return;
		if (previousVisibility.channelId === channelId && previousVisibility.visible === visible) return;
		ComponentBus.dispatch('LAYOUT_RESIZED', {channelId});
	}, [channelId, visible]);
}