Files
mattermost-mobile/app/screens/thread/index.tsx
Christopher Poile 7038a17ef4 MM-48000: Call started in another client creates a CurrentCall on mobile client (#6708)
* move creating/leaving currentCall into the connection; refactoring

* refactoring; two-stage connecting so existing screen stream can be saved

* better separation of concerns

* change warning to debug

* use getServerDatabase instead of getActiveServerDatabase

* fix bugs

* PR comments
2022-11-08 14:45:10 -05:00

29 lines
929 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 {distinctUntilChanged, switchMap} from 'rxjs/operators';
import {observeCurrentCall} from '@calls/state';
import {observePost} from '@queries/servers/post';
import Thread from './thread';
import type {WithDatabaseArgs} from '@typings/database/database';
const enhanced = withObservables(['rootId'], ({database, rootId}: WithDatabaseArgs & {rootId: string}) => {
const isInACall = observeCurrentCall().pipe(
switchMap((call) => of$(Boolean(call?.connected))),
distinctUntilChanged(),
);
return {
rootPost: observePost(database, rootId),
isInACall,
};
});
export default withDatabase(enhanced(Thread));