Files
mattermost-mobile/app/actions/remote/permalink.ts
Daniel Espino García ee3b655991 Fix permalink to not joined channels and to not fetched posts. (#6294)
* Fix permalink to not joined channels and to not fetched posts.

* i18n-extract

* Implement as designed

* Revert unintended change

* Minor fix and fix svgs

* updated svg to fix masking problems and colors

* Fix lint

* Address feedback

* Update join_public_channel.tsx

fixed public channel svg

* Update join_public_channel.tsx

* Update join_private_channel.tsx

* Address feedback

Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
2022-06-17 19:23:12 +02:00

35 lines
1.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import DatabaseManager from '@database/manager';
import {getCurrentTeam} from '@queries/servers/team';
import {displayPermalink} from '@utils/permalink';
import {PERMALINK_GENERIC_TEAM_NAME_REDIRECT} from '@utils/url';
import type TeamModel from '@typings/database/models/servers/team';
import type {IntlShape} from 'react-intl';
export const showPermalink = async (serverUrl: string, teamName: string, postId: string, intl: IntlShape, openAsPermalink = true) => {
const database = DatabaseManager.serverDatabases[serverUrl]?.database;
if (!database) {
return {error: `${serverUrl} database not found`};
}
try {
let name = teamName;
let team: TeamModel | undefined;
if (!name || name === PERMALINK_GENERIC_TEAM_NAME_REDIRECT) {
team = await getCurrentTeam(database);
if (team) {
name = team.name;
}
}
await displayPermalink(name, postId, openAsPermalink);
return {error: undefined};
} catch (error) {
return {error};
}
};