mattermost-mobile/app/screens/permalink/index.ts
Elias Nahum edef4ec4a3
Update libraries and dependencies (#7678)
* update js dependencies

* update react-native libraries

* update watermelonDB

* update RN to 0.72.7

* update fastlane

* fix remove_markdown/at_mention import

* update mattermost libraries

* update fastlane deps

* remove haptic-feedback patch

* update okhttp to 4.12.0 and patch netinfo to accurately identify VPN connections

* create ImaegStyles intersection type
2023-11-25 07:46:13 +08:00

49 lines
1.7 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {withDatabase, withObservables} from '@nozbe/watermelondb/react';
import {of as of$} from 'rxjs';
import {switchMap} from 'rxjs/operators';
import {observeChannel} from '@queries/servers/channel';
import {observePost} from '@queries/servers/post';
import {observeCurrentTeamId} from '@queries/servers/system';
import {queryMyTeamsByIds, queryTeamByName} from '@queries/servers/team';
import {observeIsCRTEnabled} from '@queries/servers/thread';
import Permalink from './permalink';
import type {WithDatabaseArgs} from '@typings/database/database';
import type PostModel from '@typings/database/models/servers/post';
type OwnProps = {
postId: PostModel['id'];
teamName?: string;
} & WithDatabaseArgs;
const enhance = withObservables([], ({database, postId, teamName}: OwnProps) => {
const post = observePost(database, postId);
const team = teamName ? queryTeamByName(database, teamName).observe().pipe(
switchMap((ts) => {
const t = ts[0];
return t ? t.observe() : of$(undefined);
}),
) : of$(undefined);
return {
channel: post.pipe(
switchMap((p) => (p ? observeChannel(database, p.channelId) : of$(undefined))),
),
rootId: post.pipe(
switchMap((p) => of$(p?.rootId)),
),
isTeamMember: team.pipe(
switchMap((t) => (t ? queryMyTeamsByIds(database, [t.id]).observe() : of$(undefined))),
switchMap((ms) => of$(Boolean(ms?.[0]))),
),
currentTeamId: observeCurrentTeamId(database),
isCRTEnabled: observeIsCRTEnabled(database),
};
});
export default withDatabase(enhance(Permalink));