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

View File

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

View File

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