mattermost-mobile/app/components/threads_button/index.ts
Daniel Espino García 9fcc6e580d
Fix GM/DM unread threads highlighting all teams as unreads (#8905)
* Fix GM/DM unread threads highlighting all teams as unreads

* Use options object instead of boolean flags

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-06-10 15:30:58 +02:00

33 lines
1.2 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 {switchMap} from 'rxjs/operators';
import {observeCurrentChannelId, observeCurrentTeamId} from '@queries/servers/system';
import {observeTeamLastChannelId} from '@queries/servers/team';
import {observeUnreadsAndMentions} 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),
lastChannelId: currentTeamId.pipe(
switchMap(
(teamId) => observeTeamLastChannelId(database, teamId),
),
),
unreadsAndMentions: currentTeamId.pipe(
switchMap(
(teamId) => observeUnreadsAndMentions(database, {teamId, includeDmGm: true}),
),
),
};
});
export default withDatabase(enhanced(ThreadsButton));