Forum: Fix topic preview disappearing after sync (#5023)

This commit is contained in:
zubiden 2024-09-27 16:11:40 +02:00 committed by Alexander Zinchuk
parent 007da552a4
commit 7859bb97fa
3 changed files with 8 additions and 12 deletions

View File

@ -113,6 +113,7 @@ type StateProps = {
lastMessageId?: number;
lastMessage?: ApiMessage;
currentUserId: string;
isSynced?: boolean;
};
const Chat: FC<OwnProps & StateProps> = ({
@ -150,6 +151,7 @@ const Chat: FC<OwnProps & StateProps> = ({
isPreview,
previewMessageId,
className,
isSynced,
onDragEnter,
}) => {
const {
@ -290,10 +292,10 @@ const Chat: FC<OwnProps & StateProps> = ({
// Load the forum topics to display unread count badge
useEffect(() => {
if (isIntersecting && isForum && listedTopicIds === undefined) {
if (isIntersecting && isForum && isSynced && listedTopicIds === undefined) {
loadTopics({ chatId });
}
}, [chatId, listedTopicIds, isForum, isIntersecting]);
}, [chatId, listedTopicIds, isSynced, isForum, isIntersecting]);
const isOnline = user && userStatus && isUserOnline(user, userStatus);
const { hasShownClass: isAvatarOnlineShown } = useShowTransitionDeprecated(isOnline);
@ -501,6 +503,7 @@ export default memo(withGlobal<OwnProps>(
currentUserId: global.currentUserId!,
listedTopicIds: topicsInfo?.listedTopicIds,
topics: topicsInfo?.topicsById,
isSynced: global.isSynced,
};
},
)(Chat));

View File

@ -27,7 +27,6 @@ export type OwnProps = {
};
type StateProps = {
isSynced?: boolean;
isLoading?: boolean;
foundIds?: string[];
recentBotIds?: string[];
@ -38,7 +37,6 @@ const runThrottled = throttle((cb) => cb(), 500, true);
const BotAppResults: FC<OwnProps & StateProps> = ({
searchQuery,
isSynced,
isLoading,
foundIds,
recentBotIds,
@ -69,13 +67,12 @@ const BotAppResults: FC<OwnProps & StateProps> = ({
});
const handleLoadMore = useCallback(({ direction }: { direction: LoadMoreDirection }) => {
if (!isSynced) return;
if (direction === LoadMoreDirection.Backwards) {
runThrottled(() => {
searchPopularBotApps();
});
}
}, [isSynced]);
}, []);
const handleToggleShowMoreMine = useLastCallback(() => {
setShouldShowMoreMine((prev) => !prev);
@ -145,7 +142,6 @@ export default memo(withGlobal<OwnProps>((global) => {
const foundIds = globalSearch.popularBotApps?.peerIds;
return {
isSynced: global.isSynced,
isLoading: !foundIds && globalSearch.fetchingStatus?.botApps,
foundIds,
recentBotIds: global.topBotApps.userIds,

View File

@ -41,7 +41,6 @@ type StateProps = {
shouldShowInChat?: boolean;
count: number;
isCurrentUserPremium: boolean;
isSynced?: boolean;
};
const SimilarChannels = ({
@ -50,7 +49,6 @@ const SimilarChannels = ({
shouldShowInChat,
count,
isCurrentUserPremium,
isSynced,
}: StateProps & OwnProps) => {
const lang = useOldLang();
const { toggleChannelRecommendations, loadChannelRecommendations } = getActions();
@ -80,10 +78,10 @@ const SimilarChannels = ({
);
useEffect(() => {
if (isSynced && !similarChannelIds) {
if (!similarChannelIds) {
loadChannelRecommendations({ chatId });
}
}, [chatId, isSynced, similarChannelIds]);
}, [chatId, similarChannelIds]);
useTimeout(() => setShoulRenderSkeleton(false), MAX_SKELETON_DELAY);
@ -249,7 +247,6 @@ export default memo(
shouldShowInChat,
count,
isCurrentUserPremium,
isSynced: global.isSynced,
};
})(SimilarChannels),
);