Files
fluxer/fluxer_app/src/features/channel/hooks/useChannelMemberListVisibility.ts
T

16 lines
667 B
TypeScript

// SPDX-License-Identifier: AGPL-3.0-or-later
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import {useEffect, useRef} from 'react';
export function useChannelMemberListVisibility(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]);
}