* showing unread and threads, of group unread setting in on * using third variable to maintain state for showing categories * removed useState from useMemo * Removed state, return orderctegroies if onlyUnreads & unreadsOnTop is true * test cases updates * removed onlyUnreads props from threads * removed onlyUnreads * test cases updated * removed unnecessary changes * removed onlyUnreads from dep --------- Co-authored-by: Mattermost Build <build@mattermost.com>
27 lines
952 B
TypeScript
27 lines
952 B
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {withDatabase, withObservables} from '@nozbe/watermelondb/react';
|
|
import {switchMap} from 'rxjs/operators';
|
|
|
|
import {observeCurrentChannelId, observeCurrentTeamId} from '@queries/servers/system';
|
|
import {observeUnreadsAndMentionsInTeam} from '@queries/servers/thread';
|
|
|
|
import ThreadsButton from './threads_button';
|
|
|
|
import type {WithDatabaseArgs} from '@typings/database/database';
|
|
|
|
const enhanced = withObservables([], ({database}: WithDatabaseArgs) => {
|
|
const currentTeamId = observeCurrentTeamId(database);
|
|
|
|
return {
|
|
currentChannelId: observeCurrentChannelId(database),
|
|
unreadsAndMentions: currentTeamId.pipe(
|
|
switchMap(
|
|
(teamId) => observeUnreadsAndMentionsInTeam(database, teamId),
|
|
),
|
|
),
|
|
};
|
|
});
|
|
|
|
export default withDatabase(enhanced(ThreadsButton));
|