Files
mattermost-mobile/app/screens/thread/thread_follow_button/index.ts
Anurag Shivarathri 8d6fc41dd5 [Gekidou MM-41093] CRT - WS Events, Actions, Queries, Thread Follow, Post Query (#6075)
* WS Events, Actions, Queries, Thread Follow, Post Query

* i18n changes

* Misc

* Only unread threads are marked as read

* Mark threads from WS even as visible in Global threads

* Merge fixes

* Update thread_post_list.tsx

* Merge fix

* Feedback fix

* Make teamId in handleThreads optional for unfollowed threads

* Removed unwated type and return

* Review changes

* Removing unused model

* Merge fix

* Misc fixes

* Following button query change
2022-04-04 19:55:13 +05:30

24 lines
830 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {withDatabase} from '@nozbe/watermelondb/DatabaseProvider';
import withObservables from '@nozbe/with-observables';
import {of as of$} from 'rxjs';
import {switchMap} from 'rxjs/operators';
import {observeThreadById} from '@queries/servers/thread';
import ThreadFollowButton from './thread_follow_button';
import type {WithDatabaseArgs} from '@typings/database/database';
const enhanced = withObservables(['threadId'], ({threadId, database}: {threadId: string} & WithDatabaseArgs) => {
return {
isFollowing: observeThreadById(database, threadId).pipe(
switchMap((thread) => of$(thread?.isFollowing)),
),
};
});
export default withDatabase(enhanced(ThreadFollowButton));