FAB: Scroll button not showing next to the Sponsored Message (#5161)

This commit is contained in:
Alexander Zinchuk 2024-11-27 20:33:28 +04:00
parent 3f3b50bc6d
commit 46c0dcb945
3 changed files with 15 additions and 15 deletions

View File

@ -296,15 +296,6 @@ const MessageListContent: FC<OwnProps> = ({
{withHistoryTriggers && <div ref={backwardsTriggerRef} key="backwards-trigger" className="backwards-trigger" />}
{shouldRenderBotInfo && <MessageListBotInfo isInMessageList key={`bot_info_${chatId}`} chatId={chatId} />}
{dateGroups.flat()}
{areAdsEnabled && isViewportNewest && (
<SponsoredMessage
key={chatId}
chatId={chatId}
containerRef={containerRef}
observeIntersectionForLoading={observeIntersectionForLoading}
observeIntersectionForPlaying={observeIntersectionForPlaying}
/>
)}
{withHistoryTriggers && (
<div
ref={forwardsTriggerRef}
@ -317,6 +308,15 @@ const MessageListContent: FC<OwnProps> = ({
key="fab-trigger"
className="fab-trigger"
/>
{areAdsEnabled && isViewportNewest && (
<SponsoredMessage
key={chatId}
chatId={chatId}
containerRef={containerRef}
observeIntersectionForLoading={observeIntersectionForLoading}
observeIntersectionForPlaying={observeIntersectionForPlaying}
/>
)}
</div>
);
};

View File

@ -66,12 +66,12 @@ export default function useScrollHooks(
}
const container = containerRef.current;
if (!container) {
return;
}
const fabTrigger = fabTriggerRef.current;
if (!container || !fabTrigger) return;
const { offsetHeight, scrollHeight, scrollTop } = container;
const scrollBottom = Math.round(scrollHeight - scrollTop - offsetHeight);
const fabOffsetTop = fabTrigger.offsetTop;
const scrollBottom = Math.round(fabOffsetTop - scrollTop - offsetHeight);
const isNearBottom = scrollBottom <= FAB_THRESHOLD;
const isAtBottom = scrollBottom <= NOTCH_THRESHOLD;

View File

@ -83,9 +83,9 @@ const SponsoredMessage: FC<OwnProps & StateProps> = ({
const lang = useOldLang();
// eslint-disable-next-line no-null/no-null
const ref = useRef<HTMLDivElement>(null);
// eslint-disable-next-line no-null/no-null
const contentRef = useRef<HTMLDivElement>(null);
// eslint-disable-next-line no-null/no-null
const ref = useRef<HTMLDivElement>(null);
const shouldObserve = Boolean(message);
const { isMobile } = useAppLayout();