* Standardize tabs across different components * Add tests and minor fixes * Remove unneeded tests * Add missing change * Fix test * Refactor to remove the component from the hook * Rename hasDot for requiresUserAttention. * Apply the changes to scheduled posts * Fix texts * Fix tests and fix minor style issue on iOS * Fix filter positioning * Fix some e2e tests * Fix tests --------- Co-authored-by: Mattermost Build <build@mattermost.com>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 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 {observeCurrentTeamId} from '@queries/servers/system';
|
|
import {queryTeamThreadsSync, queryThreadsInTeam} from '@queries/servers/thread';
|
|
import {observeTeammateNameDisplay} from '@queries/servers/user';
|
|
|
|
import ThreadsList from './threads_list';
|
|
|
|
import type {WithDatabaseArgs} from '@typings/database/database';
|
|
|
|
type Props = {
|
|
tab: GlobalThreadsTab;
|
|
teamId: string;
|
|
} & WithDatabaseArgs;
|
|
|
|
const withTeamId = withObservables([], ({database}: WithDatabaseArgs) => ({
|
|
teamId: observeCurrentTeamId(database),
|
|
}));
|
|
|
|
const enhanced = withObservables(['tab', 'teamId'], ({database, tab, teamId}: Props) => {
|
|
const getOnlyUnreads = tab !== 'all';
|
|
|
|
const teamThreadsSyncObserver = queryTeamThreadsSync(database, teamId).observeWithColumns(['earliest']);
|
|
|
|
return {
|
|
teammateNameDisplay: observeTeammateNameDisplay(database),
|
|
threads: teamThreadsSyncObserver.pipe(
|
|
switchMap((teamThreadsSync) => {
|
|
const earliest = tab === 'all' ? teamThreadsSync?.[0]?.earliest : 0;
|
|
return queryThreadsInTeam(database, teamId, getOnlyUnreads, true, true, true, earliest).observe();
|
|
}),
|
|
),
|
|
};
|
|
});
|
|
|
|
export default withDatabase(withTeamId(enhanced(ThreadsList)));
|