mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-05 10:28:54 +00:00
* [MM-67889] Fix permalinks to unjoined channels
Tapping a permalink to a post in a channel the user hasn't joined shows
"Message not viewable" instead of a join prompt. The root cause is that
GET /posts/{id} returns 403 for non-members, so fetchPostById fails and
the code never reaches the join flow.
Fall back to GET /posts/{id}/info (getPostInfo) when fetchPostById fails.
This endpoint returns channel metadata without requiring membership,
matching the web client's focusPost approach.
* Add debug logging for errors as per request
* Move getPostInfo call to remote action layer
Extract the direct NetworkManager.getClient().getPostInfo() call from
the Permalink component into a fetchPostInfo remote action in
app/actions/remote/post.ts, following the project convention that
components should not call NetworkManager directly.
* Call getPostInfo before speculatively joining team
Restructure the permalink flow so that getPostInfo (GET /posts/{id}/info)
runs first, before any team join. When the endpoint succeeds and the user
hasn't joined the channel, the join UI is shown immediately with no side
effects. Team and channel joins now happen only when the user clicks
"Join", via a new `needsTeamJoin` flag on PermalinkErrorType.
The old speculative-team-join path is preserved as a fallback for servers
that predate the /info endpoint.
Adds unit tests for the new fetchPostInfo remote action.
* Address review feedback: localize alerts, version-guard fetchPostInfo, pass database as prop
* Fix unused parameter lint error in fetchPostInfo mock
16 lines
400 B
TypeScript
16 lines
400 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
type PermalinkErrorType = {
|
|
unreachable?: boolean;
|
|
notExist?: boolean;
|
|
joinedTeam?: boolean;
|
|
needsTeamJoin?: boolean;
|
|
privateChannel?: boolean;
|
|
privateTeam?: boolean;
|
|
teamName?: string;
|
|
channelName?: string;
|
|
teamId?: string;
|
|
channelId?: string;
|
|
}
|