Commit Graph

4 Commits

Author SHA1 Message Date
Kislay Verma
67ca49488f tests: Use make_realm to create type-correct realm objects.
Another step in the direction of improving node tests
and using type-correct organic data as much as possible.
2025-08-28 11:35:07 -07:00
Prakhar Pratyush
8e1f0c4bcf topic_list: Fix "show all topics" flashing.
Earlier, 'all_topics_in_cache' used to return `false`
in the case where we were unsure if some topics were
present even before the user subscribed to the channel
and hence missing in the cache.

Returning `false` led to visible 'show all topics',
even if all the topics were already displayed. This was
helpful if the API call to fetch channel history failed,
as users had the option to make another request.

That resulted in a bug where "show all topics" was flashing
in channels with less number of topics. We used to display
"show all topics" initially and then hide it after the API
call confirmed that there were no new topics to display.

To fix this bug, we return `true`. So, the "show all topics"
is not displayed beforehand. We let the API call fetch the history
and rebuild the topic list based on the updated data.

Instead of show then hide. We now prefer, show if needed.

To fix the issue of API call failure and users having no option
to see all topics, we did prep work in the last commit
to add retry mechanism to the concerned API call.
2025-06-26 10:11:05 -07:00
Prakhar Pratyush
4515c29d44 topic_list: Fix missing 'show all topics' when messages not cached.
Earlier, when number of topics displayed in the topic list
widget was at max `topic_list_data.max_topics` and
first_message_id of stream >= first_cached_message_id.
There was a possibility of a few topics missing for messages
which were sent when the user wasn't subscribed.

We were neither displaying 'show more topics', nor fetching it
from server to update the list asyncronously.

This commit fixes that bug to display 'show all topics' in that
case and also initiates an API call in parallel to fetch all topics
for that stream and update the topic list asyncronously if topics
were actually missing.

Fixes #28949.
2025-06-19 12:43:02 -07:00
Prakhar Pratyush
7d55ad3c13 topic_list: Move and reorganize couple of functions to topic_list.ts.
A prep commit to move `is_complete_for_stream_id` and
`all_topics_in_cache` from `stream_topic_history` to `topic_list`
as it is specifically used while building topic list widget.

As it makes more sense to use `is_complete_for_stream_id` instead of
`all_topics_in_cache` directly, we reorganize to put it inside
`is_complete_for_stream_id`.

We rename `is_complete_for_stream_id` to
`is_full_topic_history_available` for clarity.

It'll also help to avoid tackling circular import issue
while resolving #28949.

No functional change in this commit.
2025-06-19 12:43:02 -07:00