-
-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TopicItem: Show actionsheet on long-press. #4608
Changes from all commits
6edf599
a3fab39
c93db0f
9634872
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
/* @flow strict-local */ | ||
import React from 'react'; | ||
import React, { useContext } from 'react'; | ||
import { View } from 'react-native'; | ||
import { useActionSheet } from '@expo/react-native-action-sheet'; | ||
|
||
import styles, { BRAND_COLOR, createStyleSheet } from '../styles'; | ||
import { RawLabel, Touchable, UnreadCount } from '../common'; | ||
import { showToast } from '../utils/info'; | ||
import { showHeaderActionSheet } from '../message/messageActionSheet'; | ||
import type { ShowActionSheetWithOptions } from '../message/messageActionSheet'; | ||
import { TranslationContext } from '../boot/TranslationProvider'; | ||
import { useDispatch, useSelector } from '../react-redux'; | ||
import { getAuth, getMute, getFlags, getSubscriptions, getOwnUser } from '../selectors'; | ||
|
||
const componentStyles = createStyleSheet({ | ||
selectedRow: { | ||
|
@@ -22,7 +27,7 @@ const componentStyles = createStyleSheet({ | |
}); | ||
|
||
type Props = $ReadOnly<{| | ||
stream?: string, | ||
stream: string, | ||
name: string, | ||
isMuted?: boolean, | ||
isSelected?: boolean, | ||
|
@@ -31,17 +36,33 @@ type Props = $ReadOnly<{| | |
|}>; | ||
|
||
export default function TopicItem(props: Props) { | ||
const { | ||
name, | ||
stream = '', | ||
isMuted = false, | ||
isSelected = false, | ||
unreadCount = 0, | ||
onPress, | ||
} = props; | ||
const { name, stream, isMuted = false, isSelected = false, unreadCount = 0, onPress } = props; | ||
|
||
const showActionSheetWithOptions: ShowActionSheetWithOptions = useActionSheet() | ||
.showActionSheetWithOptions; | ||
const _ = useContext(TranslationContext); | ||
const dispatch = useDispatch(); | ||
const backgroundData = useSelector(state => ({ | ||
auth: getAuth(state), | ||
mute: getMute(state), | ||
subscriptions: getSubscriptions(state), | ||
ownUser: getOwnUser(state), | ||
flags: getFlags(state), | ||
})); | ||
|
||
return ( | ||
<Touchable onPress={() => onPress(stream, name)} onLongPress={() => showToast(name)}> | ||
<Touchable | ||
onPress={() => onPress(stream, name)} | ||
onLongPress={() => { | ||
showHeaderActionSheet({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One bit which should be a commit of its own, but would be good to include in this PR: this name is now increasingly inapt and it'd be good to rename this to something more accurate. 🙂 There's no particular "header" involved here (like the "recipient header" in the message list, which was the original use of this), and conversely when we do have a recipient header but it's for a PM, we don't use this. Perhaps... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently this is actually only a I agree that we should rename it, but I'd prefer to punt on that until we figure out if it will in fact turn into a I suspect it'll be the latter, but I don't think I know for sure right now, so I'd rather wait to rename until I'm more sure what this will end up looking like, to save us the effort of possibly renaming it twice. |
||
showActionSheetWithOptions, | ||
callbacks: { dispatch, _ }, | ||
backgroundData, | ||
stream, | ||
topic: name, | ||
}); | ||
}} | ||
> | ||
<View | ||
style={[ | ||
styles.listItem, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
The empty string at
stream
can't have been up to anything good. I'm curious whatTopicItem
's caller inUnreadCards
is trying to accomplish by passing the empty string, but that's probably for other work outside this PR.