Skip to content

Commit

Permalink
ActionSheet [nfc]: Pass unreadStreams data to action sheet.
Browse files Browse the repository at this point in the history
This is required for mark as read functionality that will be
following this commit.
  • Loading branch information
AkashDhiman committed Jun 15, 2021
1 parent 0206d89 commit 5b0bf1b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/message/__tests__/messageActionSheet-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/message/messageActionSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
EditMessage,
Stream,
} from '../types';
import type { UnreadStreamsState } from '../unread/unreadModelTypes';
import {
getNarrowForReply,
isPmNarrow,
Expand Down Expand Up @@ -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,
Expand All @@ -229,6 +230,7 @@ export const constructTopicActionButtons = ({
mute: MuteState,
streams: Map<number, Stream>,
subscriptions: Subscription[],
unreadStreams: UnreadStreamsState,
ownUser: User,
...
}>,
Expand Down Expand Up @@ -403,6 +405,7 @@ export const showTopicActionSheet = ({
mute: MuteState,
streams: Map<number, Stream>,
subscriptions: Subscription[],
unreadStreams: UnreadStreamsState,
ownUser: User,
flags: FlagsState,
...
Expand Down
2 changes: 2 additions & 0 deletions src/streams/TopicItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
getStreamsById,
getOwnUser,
} from '../selectors';
import { getUnreadStreams } from '../unread/unreadModel';

const componentStyles = createStyleSheet({
selectedRow: {
Expand Down Expand Up @@ -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),
}));
Expand Down
4 changes: 4 additions & 0 deletions src/title/TitleStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 |},
Expand All @@ -38,6 +40,7 @@ type SelectorProps = {|
mute: MuteState,
streams: Map<number, Stream>,
subscriptions: Subscription[],
unreadStreams: UnreadStreamsState,
ownUser: User,
flags: FlagsState,
|},
Expand Down Expand Up @@ -119,6 +122,7 @@ export default connect<SelectorProps, _, _>((state, props) => ({
mute: getMute(state),
streams: getStreamsById(state),
subscriptions: getSubscriptions(state),
unreadStreams: getUnreadStreams(state),
ownUser: getOwnUser(state),
flags: getFlags(state),
},
Expand Down
4 changes: 4 additions & 0 deletions src/webview/MessageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -85,6 +87,7 @@ export type BackgroundData = $ReadOnly<{|
ownUser: User,
streams: Map<number, Stream>,
subscriptions: Subscription[],
unreadStreams: UnreadStreamsState,
theme: ThemeName,
twentyFourHourTime: boolean,
|}>;
Expand Down Expand Up @@ -365,6 +368,7 @@ export default connect<SelectorProps, _, _>((state, props: OuterProps) => {
ownUser: getOwnUser(state),
streams: getStreamsById(state),
subscriptions: getSubscriptions(state),
unreadStreams: getUnreadStreams(state),
theme: getSettings(state).theme,
twentyFourHourTime: getRealm(state).twentyFourHourTime,
};
Expand Down
1 change: 1 addition & 0 deletions src/webview/__tests__/generateInboundEvents-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('generateInboundEvents', () => {
ownUser: eg.selfUser,
streams: getStreamsById(eg.baseReduxState),
subscriptions: [],
unreadStreams: eg.baseReduxState.unread.streams,
theme: 'default',
twentyFourHourTime: false,
});
Expand Down

0 comments on commit 5b0bf1b

Please sign in to comment.