mattermost-mobile-upstream/app/screens/channel_info/options
Guillermo Vayá 2421ab967d
[MM-66467] Missing messages (#9827)
* Add failing regression test for MM-66467 missing messages

A deleted post received via RECEIVED_IN_CHANNEL (e.g. from the cold-start
deferred unread-channel fetch, since GetPostsSince returns deleted posts)
currently creates a separate, empty PostsInChannel interval. That interval
has the newest `latest`, becomes postsInChannel[0], renders zero rows, and
blanks the channel.

This operator-level test seeds a real [1000,1000] interval, then handles a
deleted post at create_at 5000 and asserts no empty orphan interval is
created. It is intentionally RED on current code (after.length is 2, not 1)
and will pass once the creation-site fix (build the interval from
delete_at===0 posts / skip when none survive) lands.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Add "Reset cached messages" channel recovery option (MM-66467)

Adds a "Reset cached messages" option at the bottom of the Channel Info
options list (directly above "Leave channel"), visible to every channel
member. It clears the channel's local posts + PostsInChannel intervals and
resets lastFetchedAt via deletePostsForChannel, then re-fetches a clean
page from the server via fetchPostsForChannel.

This recovers a channel that renders blank due to an empty/orphaned
PostsInChannel interval (e.g. the deleted-root + deferred-fetch path), and
is robust to any future cause of a bad interval state, without requiring a
full logout/login.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Navigate to the channel after resetting cached messages

After confirming "Reset cached messages", dismiss the Channel Info screen
via navigateBack() so the user lands back on the now-repopulated channel
instead of staying in Channel Info.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Show distinct errors for reset delete vs fetch failures

Split the single try/catch in the reset action into two checks against the
returned error:
- if deletePostsForChannel fails, show a generic "couldn't reset" message
  and stop (nothing was changed).
- if fetchPostsForChannel fails, tell the user the cached messages were
  cleared but couldn't be downloaded again and to check their internet
  connection.

Only navigate back to the channel when both steps succeed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Fix MM-66467: don't create PostsInChannel interval from deleted posts

handleReceivedPostsInChannel built the channel interval from the raw posts
array, including posts with delete_at > 0. Those posts are dropped before
persistence (handlePosts), so a deleted post newer than the existing
interval produced an empty, orphaned chunk that became postsInChannel[0]
and rendered the whole channel blank.

Filter to delete_at === 0 posts before computing the interval edges, and
skip interval creation entirely when none survive. This is the creation-
site fix: it prevents the orphan rather than cleaning it up afterwards, so
it does not mask genuine gaps the way an aggressive chunk merge would.

Makes the previously-failing operator regression test pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Extend chunk on deferred since-fetch instead of orphaning (MM-66467)

processChannelPostsByTeam (the cold-start "fetch posts for unread channels"
pass) stored its results with a hardcoded RECEIVED_IN_CHANNEL, ignoring the
action type fetchPostsForChannel resolved. A since-fetch is a contiguous
continuation of the channel's existing interval, so storing it as
RECEIVED_IN_CHANNEL created a disjoint interval for any post newer than the
chunk instead of extending it — an orphan that can become postsInChannel[0]
and hide the channel.

Use the resolved action type (RECEIVED_SINCE for a since-fetch, which
extends the existing chunk; RECEIVED_IN_CHANNEL only for an initial page
fetch with no chunk yet). This matches what fetchPostsForChannel does when
it stores its own results.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Await server database teardown in post.auxiliary test

afterEach called DatabaseManager.destroyServerDatabase without awaiting it,
so teardown could race the next test's beforeEach/init. Await it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 11:20:58 +02:00
..
add_members Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
auto_follow_threads Remove tand prevent double tap (#9078) 2025-08-25 12:03:01 +02:00
channel_files Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
channel_settings Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
ignore_mentions Remove tand prevent double tap (#9078) 2025-08-25 12:03:01 +02:00
members Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
my_autotranslation Add autotranslations (#9324) 2026-02-10 17:50:39 +01:00
notification_preference Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
pinned_messages Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
reset_channel_posts [MM-66467] Missing messages (#9827) 2026-06-15 11:20:58 +02:00
index.test.tsx Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
index.tsx [MM-66467] Missing messages (#9827) 2026-06-15 11:20:58 +02:00