mattermost-mobile/app/components/channel_actions/favorite_box/index.ts
Elias Nahum 4573732fd2
[Gekidou] channel quick actions (#6288)
* Add hitSlop to navigation header right buttons

* Fix channel_item info muted style

* Fix team switch when global threads

* Wrap WS channel events in try/catch

* Group Box component and Animated Group Box

* SlideUpPanelItem style

* Fix return value of setCurrentTeamAndChannelId

* Add observeChannelSettings and include channel settings in prepareDeleteChannel

* update OPTIONS_HEIGHT reference in find channels quick options

* Fix DM limit in channel list

* Fix category header style and translate default categories

* Add snackbar for unmute/favorite/unfavorite

* Add toggleFavoriteChannel remote action

* Add makeDirectChannelVisible remote action

* Use makeDirectChannelVisible in switchToChannelById and update toggleMuteChannel snackbar

* Add channel actions common components

* Update channel intro to use channel action common components

* Rename ChannelDetails screen to ChannelInfo

* Add channel quick actions

* Update localization strings

* Fix addChannelToDefaultCategory

* Leave channel

* Add localization strings

* Fix snackBar screen event listener

* Feedback review
2022-05-19 14:30:55 -04:00

36 lines
1.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// 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 {combineLatestWith, switchMap} from 'rxjs/operators';
import {observeIsChannelFavorited} from '@queries/servers/categories';
import {observeChannel} from '@queries/servers/channel';
import {observeCurrentTeamId} from '@queries/servers/system';
import FavoriteBox from './favorite_box';
import type {WithDatabaseArgs} from '@typings/database/database';
type OwnProps = WithDatabaseArgs & {
channelId: string;
}
const enhanced = withObservables(['channelId'], ({channelId, database}: OwnProps) => {
const currentTeamId = observeCurrentTeamId(database);
const channel = observeChannel(database, channelId);
const isFavorited = channel.pipe(
combineLatestWith(currentTeamId),
switchMap(([c, tId]) => observeIsChannelFavorited(database, c?.teamId || tId, channelId)),
);
return {
isFavorited,
};
});
export default withDatabase(enhanced(FavoriteBox));