-
Notifications
You must be signed in to change notification settings - Fork 75
feat(comments): replace the legacy options menu with the post options sheet #3405
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
Changes from all commits
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,13 +1,12 @@ | ||
| import React, { useState, Fragment, useRef } from 'react'; | ||
| import React, { Fragment, useRef } from 'react'; | ||
| import { Text } from 'react-native'; | ||
| import get from 'lodash/get'; | ||
| import { useIntl } from 'react-intl'; | ||
| import EStyleSheet from 'react-native-extended-stylesheet'; | ||
|
|
||
| // Components | ||
| import { FlashList } from '@shopify/flash-list'; | ||
| import { Comment, TextButton, UpvotePopover } from '../..'; | ||
| import { OptionsModal } from '../../atoms'; | ||
| import { Comment, PostOptionsModal, TextButton, UpvotePopover } from '../..'; | ||
| import { PostHtmlInteractionHandler } from '../../postHtmlRenderer'; | ||
|
|
||
| // Styles | ||
|
|
@@ -24,7 +23,6 @@ const CommentsView = ({ | |
| fetchPost, | ||
| handleDeleteComment, | ||
| handleOnEditPress, | ||
| handleOnPressCommentMenu, | ||
| handleOnReplyPress, | ||
| handleOnUserPress, | ||
| handleOnVotersPress, | ||
|
|
@@ -46,21 +44,36 @@ const CommentsView = ({ | |
| onTagPress, | ||
| onAuthorPress, | ||
| }) => { | ||
| const [selectedComment, setSelectedComment] = useState(null); | ||
| const intl = useIntl(); | ||
| const commentMenu = useRef<any>(); | ||
| // Surfaces that pass `handleOnOptionsPress` (waves) route to their own sheet. | ||
| // Everywhere else used to fall back to a four-item menu with no delete, edit, | ||
| // report or moderation action; it now gets the same sheet the post detail | ||
| // screen uses. | ||
| const postOptionsModalRef = useRef<any>(null); | ||
| const upvotePopoverRef = useRef(); | ||
| const postInteractionRef = useRef(null); | ||
|
|
||
| const _openCommentMenu = (item) => { | ||
| if (handleOnOptionsPress) { | ||
| handleOnOptionsPress(item); | ||
| } else if (commentMenu.current) { | ||
| setSelectedComment(item); | ||
| commentMenu.current.show(); | ||
| } else if (postOptionsModalRef.current) { | ||
| postOptionsModalRef.current.show(item); | ||
| } | ||
| }; | ||
|
|
||
| // Without this the sheet falls back to its own delete, which calls | ||
| // navigation.goBack() and would pop the profile or bot-comments screen the | ||
| // list is embedded in. It would also skip the in-place list removal and, on | ||
| // waves, the container's wave-specific delete path. | ||
| const _handleDeleteFromMenu = (item) => | ||
| handleDeleteComment( | ||
| item.permlink, | ||
| item.parent_permlink, | ||
| item.parent_author, | ||
| item.root_author, | ||
| item.root_permlink, | ||
| ); | ||
|
|
||
| const _openReplyThread = (item) => { | ||
| if (item && openReplyThread) { | ||
| openReplyThread(item); | ||
|
|
@@ -73,11 +86,6 @@ const CommentsView = ({ | |
| } | ||
| }; | ||
|
|
||
| const _onMenuItemPress = (index) => { | ||
| handleOnPressCommentMenu(index, selectedComment); | ||
| setSelectedComment(null); | ||
| }; | ||
|
|
||
| const _onUpvotePress = ({ content, sourceRef, showPayoutDetails, onVotingStart }) => { | ||
| if (upvotePopoverRef.current) { | ||
| const postType = isWavesHost(content.parent_author) ? PostTypes.WAVE : PostTypes.COMMENT; | ||
|
|
@@ -92,13 +100,6 @@ const CommentsView = ({ | |
| } | ||
| }; | ||
|
|
||
| const menuItems = [ | ||
| intl.formatMessage({ id: 'post.copy_link' }), | ||
| intl.formatMessage({ id: 'post.copy_text' }), | ||
| intl.formatMessage({ id: 'post.open_thread' }), | ||
| intl.formatMessage({ id: 'alert.cancel' }), | ||
| ]; | ||
|
|
||
| if (!hideManyCommentsButton && hasManyComments) { | ||
| return ( | ||
| <TextButton | ||
|
|
@@ -186,12 +187,11 @@ const CommentsView = ({ | |
| {...flatListProps} | ||
| /> | ||
| {!handleOnOptionsPress && ( | ||
| <OptionsModal | ||
| ref={commentMenu} | ||
| options={menuItems} | ||
| title={get(selectedComment, 'summary')} | ||
| cancelButtonIndex={3} | ||
| onPress={_onMenuItemPress} | ||
| <PostOptionsModal | ||
| ref={postOptionsModalRef} | ||
| isVisibleTranslateModal={true} | ||
| onOpenThread={_openReplyThread} | ||
|
Comment on lines
+190
to
+193
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.
When a user selects Delete for an owned, deletable comment on any newly converted list surface, this modal receives no Useful? React with 👍 / 👎.
Member
Author
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. Confirmed and fixed in a371e95. Both of you flagged this independently and it was the real defect in the PR. Traced it: The list already had the right handler; the sheet just was not given it. const _handleDeleteFromMenu = (item) =>
handleDeleteComment(
item.permlink, item.parent_permlink, item.parent_author,
item.root_author, item.root_permlink,
);Worth noting this is exactly the failure mode the existing comment on
coderabbitai[bot] marked this conversation as resolved.
|
||
| onDelete={_handleDeleteFromMenu} | ||
| /> | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| )} | ||
| <UpvotePopover ref={upvotePopoverRef} /> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.