From ce9a4f8cc7d48b5917465eebfe7682023d9815bc Mon Sep 17 00:00:00 2001 From: RoberTu Date: Mon, 28 Oct 2019 21:04:12 +0800 Subject: [PATCH 1/4] Show toast after unblock user; Fix bugs; --- src/common/enums/text.ts | 2 + .../Button/BlockUser/Dropdown/index.tsx | 23 +++++- .../Button/BlockUser/Unblock/index.tsx | 23 +++++- .../Collection/CollectionList.tsx | 4 +- .../Responses/FeaturedComments.tsx | 6 +- .../Responses/LatestResponses.tsx | 6 +- src/views/Follow/FollowFeed/index.tsx | 82 ++++++++++--------- src/views/Tags/index.tsx | 2 +- 8 files changed, 94 insertions(+), 54 deletions(-) diff --git a/src/common/enums/text.ts b/src/common/enums/text.ts index f50ab91b48..235ff659da 100644 --- a/src/common/enums/text.ts +++ b/src/common/enums/text.ts @@ -135,6 +135,7 @@ export const TEXT = { blockUser: '屏蔽用戶', unblockUser: '取消屏蔽', blockSuccess: '屏蔽成功', + unblockSuccess: '已取消屏蔽。該用戶現在可以評論你的作品。', pin: '喜歡回應', unpin: '取消精選', emptySearchResults: '沒有找到你搜索的內容', @@ -308,6 +309,7 @@ export const TEXT = { blockUser: '屏蔽用户', unblockUser: '取消屏蔽', blockSuccess: '屏蔽成功', + unblockSuccess: '已取消屏蔽。该用户现在可以评论你的作品。', pin: '喜欢回应', unpin: '取消精选', emptySearchResults: '没有找到你搜寻的内容', diff --git a/src/components/Button/BlockUser/Dropdown/index.tsx b/src/components/Button/BlockUser/Dropdown/index.tsx index 5ee34a2575..9d27016494 100644 --- a/src/components/Button/BlockUser/Dropdown/index.tsx +++ b/src/components/Button/BlockUser/Dropdown/index.tsx @@ -1,13 +1,17 @@ +import { useContext } from 'react' + import { Icon, TextIcon, Translate } from '~/components' import { useMutation } from '~/components/GQL' import { BlockUser } from '~/components/GQL/fragments/__generated__/BlockUser' import userFragments from '~/components/GQL/fragments/user' import { UnblockUser } from '~/components/GQL/mutations/__generated__/UnblockUser' import UNBLOCK_USER from '~/components/GQL/mutations/unblockUser' +import { LanguageContext } from '~/components/Language' import BlocKUserModal from '~/components/Modal/BlockUserModal' import { ModalInstance, ModalSwitch } from '~/components/ModalManager' -import { TEXT } from '~/common/enums' +import { ADD_TOAST, TEXT } from '~/common/enums' +import { translate } from '~/common/utils' import ICON_BLOCK from '~/static/icons/block.svg?sprite' import ICON_UNBLOCK from '~/static/icons/unblock.svg?sprite' @@ -49,6 +53,7 @@ const BlockUserButton = ({ isShown: boolean hideDropdown: () => void }) => { + const { lang } = useContext(LanguageContext) const [unblockUser] = useMutation(UNBLOCK_USER, { variables: { id: user.id }, optimisticResponse: { @@ -65,8 +70,20 @@ const BlockUserButton = ({ {user.isBlocked && ( + + {(open: any) => ( + + )} + ) } return ( - + + {(open: any) => ( + + )} + ) } diff --git a/src/components/CommentDigest/FooterActions/UpvoteButton.tsx b/src/components/CommentDigest/FooterActions/UpvoteButton.tsx index b38a34e345..c490eca96b 100644 --- a/src/components/CommentDigest/FooterActions/UpvoteButton.tsx +++ b/src/components/CommentDigest/FooterActions/UpvoteButton.tsx @@ -14,6 +14,9 @@ import ICON_LIKE_ACTIVE from '~/static/icons/like-active.svg?sprite' import ICON_LIKE_INACTIVE from '~/static/icons/like-inactive.svg?sprite' import { UpvoteComment } from './__generated__/UpvoteComment' +import { ModalSwitch } from '~/components/ModalManager' +import { useContext } from 'react' +import { ViewerContext } from '~/components/Viewer' const fragments = { comment: gql` @@ -48,6 +51,7 @@ const UpvoteButton = ({ comment: UpvoteComment disabled?: boolean }) => { + const viewer = useContext(ViewerContext) const [unvote] = useMutation(UNVOTE_COMMENT, { variables: { id: comment.id }, optimisticResponse: { @@ -76,30 +80,58 @@ const UpvoteButton = ({ if (comment.myVote === 'up') { return ( - + + {(open: any) => ( + + )} + ) } return ( - + + {(open: any) => ( + + )} + ) } diff --git a/src/components/CommentDigest/FooterActions/index.tsx b/src/components/CommentDigest/FooterActions/index.tsx index e18e8af93c..3316b9e58a 100644 --- a/src/components/CommentDigest/FooterActions/index.tsx +++ b/src/components/CommentDigest/FooterActions/index.tsx @@ -120,7 +120,7 @@ const FooterActions: React.FC & { type="button" className={showForm ? 'active' : ''} onClick={() => { - if (viewer.isOnboarding || !viewer.likerId) { + if (viewer.shouldSetupLikerID) { open() } else { setShowForm(!showForm) diff --git a/src/components/Form/CommentForm/index.tsx b/src/components/Form/CommentForm/index.tsx index d43f6876dc..675c360979 100644 --- a/src/components/Form/CommentForm/index.tsx +++ b/src/components/Form/CommentForm/index.tsx @@ -196,7 +196,7 @@ const CommentForm = ({ export default (props: CommentFormProps) => { const viewer = useContext(ViewerContext) - if (viewer.isOnboarding || !viewer.likerId) { + if (viewer.shouldSetupLikerID) { return ( {(open: any) => ( diff --git a/src/components/GlobalHeader/index.tsx b/src/components/GlobalHeader/index.tsx index f21edc7b61..9b4a95add2 100644 --- a/src/components/GlobalHeader/index.tsx +++ b/src/components/GlobalHeader/index.tsx @@ -61,10 +61,10 @@ export const GlobalHeader = ({ user }: { user: GlobalHeaderUser }) => { {isMediumUp ? : } - {isDraft && (viewer.isActive || viewer.isOnboarding) && ( + {isDraft && (viewer.isActive || viewer.shouldSetupLikerID) && ( )} - {!isDraft && (viewer.isActive || viewer.isOnboarding) && ( + {!isDraft && (viewer.isActive || viewer.shouldSetupLikerID) && ( )} diff --git a/src/components/Modal/Anchor/index.tsx b/src/components/Modal/Anchor/index.tsx index da65bde067..43b5a5e2f3 100644 --- a/src/components/Modal/Anchor/index.tsx +++ b/src/components/Modal/Anchor/index.tsx @@ -53,7 +53,7 @@ const Anchor = () => { viewer.isAuthed && !isLikeCoinClosed && isLikeCoinAllowPaths && - (viewer.isOnboarding || !viewer.likerId) + viewer.shouldSetupLikerID const closeLikeCoinModal = () => { setIsLikeCoinClosed(true) } diff --git a/src/components/Viewer/index.tsx b/src/components/Viewer/index.tsx index 4de3ca660f..9bb4c6aa58 100644 --- a/src/components/Viewer/index.tsx +++ b/src/components/Viewer/index.tsx @@ -40,6 +40,7 @@ type Viewer = ViewerUser & { isOnboarding: boolean isInactive: boolean isAdmin: boolean + shouldSetupLikerID: boolean } export const processViewer = (viewer: ViewerUser): Viewer => { @@ -53,6 +54,7 @@ export const processViewer = (viewer: ViewerUser): Viewer => { const isOnboarding = state === 'onboarding' const isInactive = isAuthed && (isFrozen || isBanned || isArchived) const isAdmin = role === 'admin' + const shouldSetupLikerID = isOnboarding || !viewer.likerId // Add user info for Sentry Sentry.configureScope((scope: any) => { @@ -73,7 +75,8 @@ export const processViewer = (viewer: ViewerUser): Viewer => { isFrozen, isOnboarding, isInactive, - isAdmin + isAdmin, + shouldSetupLikerID } } diff --git a/src/views/ArticleDetail/Toolbar/AppreciationButton/index.tsx b/src/views/ArticleDetail/Toolbar/AppreciationButton/index.tsx index 817aada55c..1a3205aea6 100644 --- a/src/views/ArticleDetail/Toolbar/AppreciationButton/index.tsx +++ b/src/views/ArticleDetail/Toolbar/AppreciationButton/index.tsx @@ -175,7 +175,7 @@ const AppreciationButtonContainer = ({ isAuthed: viewer.isAuthed } - if (viewer.isOnboarding) { + if (viewer.shouldSetupLikerID) { return (
From 46e413b9483bedf99eb7c0299a165b2d310addfc Mon Sep 17 00:00:00 2001 From: RoberTu Date: Mon, 28 Oct 2019 22:41:19 +0800 Subject: [PATCH 3/4] Fix format --- .../CommentDigest/FooterActions/DownvoteButton.tsx | 6 +++--- src/components/CommentDigest/FooterActions/UpvoteButton.tsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/CommentDigest/FooterActions/DownvoteButton.tsx b/src/components/CommentDigest/FooterActions/DownvoteButton.tsx index 1a09477249..587847f2ff 100644 --- a/src/components/CommentDigest/FooterActions/DownvoteButton.tsx +++ b/src/components/CommentDigest/FooterActions/DownvoteButton.tsx @@ -1,4 +1,5 @@ import gql from 'graphql-tag' +import { useContext } from 'react' import { Icon, TextIcon } from '~/components' import { useMutation } from '~/components/GQL' @@ -8,15 +9,14 @@ import { UNVOTE_COMMENT, VOTE_COMMENT } from '~/components/GQL/mutations/voteComment' +import { ModalSwitch } from '~/components/ModalManager' +import { ViewerContext } from '~/components/Viewer' import { numAbbr } from '~/common/utils' import ICON_DISLIKE_ACTIVE from '~/static/icons/dislike-active.svg?sprite' import ICON_DISLIKE_INACTIVE from '~/static/icons/dislike-inactive.svg?sprite' import { DownvoteComment } from './__generated__/DownvoteComment' -import { ModalSwitch } from '~/components/ModalManager' -import { useContext } from 'react' -import { ViewerContext } from '~/components/Viewer' const fragments = { comment: gql` diff --git a/src/components/CommentDigest/FooterActions/UpvoteButton.tsx b/src/components/CommentDigest/FooterActions/UpvoteButton.tsx index c490eca96b..b836b6d9f4 100644 --- a/src/components/CommentDigest/FooterActions/UpvoteButton.tsx +++ b/src/components/CommentDigest/FooterActions/UpvoteButton.tsx @@ -1,4 +1,5 @@ import gql from 'graphql-tag' +import { useContext } from 'react' import { Icon, TextIcon } from '~/components' import { useMutation } from '~/components/GQL' @@ -8,15 +9,14 @@ import { UNVOTE_COMMENT, VOTE_COMMENT } from '~/components/GQL/mutations/voteComment' +import { ModalSwitch } from '~/components/ModalManager' +import { ViewerContext } from '~/components/Viewer' import { numAbbr } from '~/common/utils' import ICON_LIKE_ACTIVE from '~/static/icons/like-active.svg?sprite' import ICON_LIKE_INACTIVE from '~/static/icons/like-inactive.svg?sprite' import { UpvoteComment } from './__generated__/UpvoteComment' -import { ModalSwitch } from '~/components/ModalManager' -import { useContext } from 'react' -import { ViewerContext } from '~/components/Viewer' const fragments = { comment: gql` From a982f42f90013106abbb12f8839f93a22a83f60c Mon Sep 17 00:00:00 2001 From: RoberTu Date: Tue, 29 Oct 2019 14:45:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?Change=20zh=5Fhant=20translations=20of=20"b?= =?UTF-8?q?lock"=20to=20"=E5=B0=81=E9=8E=96"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/enums/text.ts | 12 ++++++------ src/components/Modal/BlockUserModal/index.tsx | 4 ++-- src/views/Me/Settings/Blocked/SettingsBlocked.tsx | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/common/enums/text.ts b/src/common/enums/text.ts index 235ff659da..49a249c996 100644 --- a/src/common/enums/text.ts +++ b/src/common/enums/text.ts @@ -121,7 +121,7 @@ export const TEXT = { setting: '設定', accountSetting: '帳戶設定', notificationSetting: '通知設定', - blockedSetting: '屏蔽用戶', + blockedSetting: '封鎖用戶', walletSetting: '錢包設定', uiSetting: '介面設定', userProfile: '個人簡介', @@ -131,11 +131,11 @@ export const TEXT = { articleFingerprint: '作品指紋', copySuccess: '複製成功', copy: '複製', - block: '屏蔽', - blockUser: '屏蔽用戶', - unblockUser: '取消屏蔽', - blockSuccess: '屏蔽成功', - unblockSuccess: '已取消屏蔽。該用戶現在可以評論你的作品。', + block: '封鎖', + blockUser: '封鎖用戶', + unblockUser: '取消封鎖', + blockSuccess: '封鎖成功', + unblockSuccess: '已取消封鎖。該用戶現在可以評論你的作品。', pin: '喜歡回應', unpin: '取消精選', emptySearchResults: '沒有找到你搜索的內容', diff --git a/src/components/Modal/BlockUserModal/index.tsx b/src/components/Modal/BlockUserModal/index.tsx index 7760d715e1..8fb25adc89 100644 --- a/src/components/Modal/BlockUserModal/index.tsx +++ b/src/components/Modal/BlockUserModal/index.tsx @@ -51,12 +51,12 @@ const BlocKUserModal: React.FC = ({ <>
diff --git a/src/views/Me/Settings/Blocked/SettingsBlocked.tsx b/src/views/Me/Settings/Blocked/SettingsBlocked.tsx index 8216f917cd..588b9f7a16 100644 --- a/src/views/Me/Settings/Blocked/SettingsBlocked.tsx +++ b/src/views/Me/Settings/Blocked/SettingsBlocked.tsx @@ -62,7 +62,7 @@ const SettingsBlocked = () => { return ( + } /> )