Similar Channels: Fix animation (#6778)
This commit is contained in:
parent
214e8a3c75
commit
88b6d3a6d7
@ -61,6 +61,12 @@
|
||||
background: var(--color-background);
|
||||
}
|
||||
|
||||
.channelsWrapper {
|
||||
transform: scale(0) translateY(-50%);
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.is-appearing {
|
||||
animation: 0.15s ease-out channels-appear forwards;
|
||||
}
|
||||
|
||||
@ -67,6 +67,13 @@ const SimilarChannels = ({
|
||||
const ref = useRef<HTMLDivElement>();
|
||||
|
||||
const ignoreAutoScrollRef = useRef(false);
|
||||
const wasExpandedRef = useRef(false);
|
||||
const wasClosedManuallyRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
wasClosedManuallyRef.current = false;
|
||||
}, [chatId]);
|
||||
|
||||
const similarChannels = useMemo(() => {
|
||||
if (!similarChannelIds) {
|
||||
return undefined;
|
||||
@ -111,6 +118,7 @@ const SimilarChannels = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (isExpanded) {
|
||||
wasExpandedRef.current = true;
|
||||
markShowing();
|
||||
markNotHiding();
|
||||
setShouldRenderSkeleton(!similarChannelIds);
|
||||
@ -119,18 +127,21 @@ const SimilarChannels = ({
|
||||
ref.current?.scrollIntoView({ behavior: 'smooth' });
|
||||
}, ANIMATION_DURATION);
|
||||
}
|
||||
} else {
|
||||
} else if (wasExpandedRef.current) {
|
||||
markNotShowing();
|
||||
markHiding();
|
||||
}
|
||||
}, [isExpanded, similarChannelIds]);
|
||||
|
||||
const handleToggle = useLastCallback(() => {
|
||||
if (isExpanded) {
|
||||
wasClosedManuallyRef.current = true;
|
||||
}
|
||||
toggleChannelRecommendations({ chatId });
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!channelJoinInfo?.joinedDate || isExpanded) return;
|
||||
if (!channelJoinInfo?.joinedDate || isExpanded || wasClosedManuallyRef.current) return;
|
||||
if (getServerTime() - channelJoinInfo.joinedDate <= AUTO_EXPAND_TIME) {
|
||||
handleToggle();
|
||||
ignoreAutoScrollRef.current = true;
|
||||
@ -147,6 +158,7 @@ const SimilarChannels = ({
|
||||
{shouldRenderChannels && (
|
||||
<div
|
||||
className={buildClassName(
|
||||
styles.channelsWrapper,
|
||||
isShowing && styles.isAppearing,
|
||||
isHiding && styles.isHiding,
|
||||
)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user