From 5b0bf1bc2d68c6969ef76be8a445eae0a1c87f9e Mon Sep 17 00:00:00 2001 From: Akash Date: Thu, 10 Jun 2021 19:56:22 +0530 Subject: [PATCH] ActionSheet [nfc]: Pass unreadStreams data to action sheet. This is required for mark as read functionality that will be following this commit. --- src/message/__tests__/messageActionSheet-test.js | 1 + src/message/messageActionSheet.js | 5 ++++- src/streams/TopicItem.js | 2 ++ src/title/TitleStream.js | 4 ++++ src/webview/MessageList.js | 4 ++++ src/webview/__tests__/generateInboundEvents-test.js | 1 + 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/message/__tests__/messageActionSheet-test.js b/src/message/__tests__/messageActionSheet-test.js index 93de178983c..f6e1bc32521 100644 --- a/src/message/__tests__/messageActionSheet-test.js +++ b/src/message/__tests__/messageActionSheet-test.js @@ -19,6 +19,7 @@ const baseBackgroundData = deepFreeze({ subscriptions: [], theme: 'default', twentyFourHourTime: false, + unreadStreams: eg.baseReduxState.unread.streams, }); const buttonTitles = buttons => buttons.map(button => button.title); diff --git a/src/message/messageActionSheet.js b/src/message/messageActionSheet.js index e5a2d9ef15b..19b0aeba6b5 100644 --- a/src/message/messageActionSheet.js +++ b/src/message/messageActionSheet.js @@ -16,6 +16,7 @@ import type { EditMessage, Stream, } from '../types'; +import type { UnreadStreamsState } from '../unread/unreadModelTypes'; import { getNarrowForReply, isPmNarrow, @@ -220,7 +221,7 @@ cancel.title = 'Cancel'; cancel.errorMessage = 'Failed to hide menu'; export const constructTopicActionButtons = ({ - backgroundData: { mute, ownUser, streams, subscriptions }, + backgroundData: { mute, ownUser, streams, subscriptions, unreadStreams }, streamName, streamId, topic, @@ -229,6 +230,7 @@ export const constructTopicActionButtons = ({ mute: MuteState, streams: Map, subscriptions: Subscription[], + unreadStreams: UnreadStreamsState, ownUser: User, ... }>, @@ -403,6 +405,7 @@ export const showTopicActionSheet = ({ mute: MuteState, streams: Map, subscriptions: Subscription[], + unreadStreams: UnreadStreamsState, ownUser: User, flags: FlagsState, ... diff --git a/src/streams/TopicItem.js b/src/streams/TopicItem.js index ad9fa9d791a..8f784f37233 100644 --- a/src/streams/TopicItem.js +++ b/src/streams/TopicItem.js @@ -18,6 +18,7 @@ import { getStreamsById, getOwnUser, } from '../selectors'; +import { getUnreadStreams } from '../unread/unreadModel'; const componentStyles = createStyleSheet({ selectedRow: { @@ -55,6 +56,7 @@ export default function TopicItem(props: Props) { mute: getMute(state), streams: getStreamsById(state), subscriptions: getSubscriptions(state), + unreadStreams: getUnreadStreams(state), ownUser: getOwnUser(state), flags: getFlags(state), })); diff --git a/src/title/TitleStream.js b/src/title/TitleStream.js index 82f5602896e..be8d7d37957 100644 --- a/src/title/TitleStream.js +++ b/src/title/TitleStream.js @@ -30,6 +30,8 @@ import { } from '../selectors'; import { showTopicActionSheet } from '../message/messageActionSheet'; import type { ShowActionSheetWithOptions } from '../message/messageActionSheet'; +import type { UnreadStreamsState } from '../unread/unreadModelTypes'; +import { getUnreadStreams } from '../unread/unreadModel'; type SelectorProps = {| stream: Subscription | {| ...Stream, in_home_view: boolean |}, @@ -38,6 +40,7 @@ type SelectorProps = {| mute: MuteState, streams: Map, subscriptions: Subscription[], + unreadStreams: UnreadStreamsState, ownUser: User, flags: FlagsState, |}, @@ -119,6 +122,7 @@ export default connect((state, props) => ({ mute: getMute(state), streams: getStreamsById(state), subscriptions: getSubscriptions(state), + unreadStreams: getUnreadStreams(state), ownUser: getOwnUser(state), flags: getFlags(state), }, diff --git a/src/webview/MessageList.js b/src/webview/MessageList.js index 35eebe26262..53eecc5facd 100644 --- a/src/webview/MessageList.js +++ b/src/webview/MessageList.js @@ -59,6 +59,8 @@ import { handleWebViewOutboundEvent } from './handleOutboundEvents'; import { base64Utf8Encode } from '../utils/encoding'; import * as logging from '../utils/logging'; import { tryParseUrl } from '../utils/url'; +import type { UnreadStreamsState } from '../unread/unreadModelTypes'; +import { getUnreadStreams } from '../unread/unreadModel'; // ESLint doesn't notice how `this.props` escapes, and complains about some // props not being used here. @@ -85,6 +87,7 @@ export type BackgroundData = $ReadOnly<{| ownUser: User, streams: Map, subscriptions: Subscription[], + unreadStreams: UnreadStreamsState, theme: ThemeName, twentyFourHourTime: boolean, |}>; @@ -365,6 +368,7 @@ export default connect((state, props: OuterProps) => { ownUser: getOwnUser(state), streams: getStreamsById(state), subscriptions: getSubscriptions(state), + unreadStreams: getUnreadStreams(state), theme: getSettings(state).theme, twentyFourHourTime: getRealm(state).twentyFourHourTime, }; diff --git a/src/webview/__tests__/generateInboundEvents-test.js b/src/webview/__tests__/generateInboundEvents-test.js index e24c612102c..fc2607b9f3a 100644 --- a/src/webview/__tests__/generateInboundEvents-test.js +++ b/src/webview/__tests__/generateInboundEvents-test.js @@ -21,6 +21,7 @@ describe('generateInboundEvents', () => { ownUser: eg.selfUser, streams: getStreamsById(eg.baseReduxState), subscriptions: [], + unreadStreams: eg.baseReduxState.unread.streams, theme: 'default', twentyFourHourTime: false, });