From c75ecefb09e3312a7faf14bb031c44b2e448bd25 Mon Sep 17 00:00:00 2001 From: xmflsct Date: Mon, 31 Oct 2022 21:54:24 +0100 Subject: [PATCH] Fixed #424 --- src/components/Relationship/Outgoing.tsx | 2 +- src/components/Timeline/Shared/Actions.tsx | 78 +++++----------------- src/screens/Compose.tsx | 4 +- 3 files changed, 17 insertions(+), 67 deletions(-) diff --git a/src/components/Relationship/Outgoing.tsx b/src/components/Relationship/Outgoing.tsx index 13c9b229..123ac90d 100644 --- a/src/components/Relationship/Outgoing.tsx +++ b/src/components/Relationship/Outgoing.tsx @@ -33,7 +33,7 @@ const RelationshipOutgoing = React.memo( queryKeyRelationship, [res] ) - if (action === 'follow' || action === 'block') { + if (action === 'block') { const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Following' }] queryClient.invalidateQueries(queryKey) } diff --git a/src/components/Timeline/Shared/Actions.tsx b/src/components/Timeline/Shared/Actions.tsx index 654c47ec..ddf1fdd3 100644 --- a/src/components/Timeline/Shared/Actions.tsx +++ b/src/components/Timeline/Shared/Actions.tsx @@ -48,40 +48,18 @@ const TimelineActions: React.FC = ({ const theParams = params as MutationVarsTimelineUpdateStatusProperty if ( // Un-bookmark from bookmarks page - (queryKey[1].page === 'Bookmarks' && - theParams.payload.property === 'bookmarked') || + (queryKey[1].page === 'Bookmarks' && theParams.payload.property === 'bookmarked') || // Un-favourite from favourites page - (queryKey[1].page === 'Favourites' && - theParams.payload.property === 'favourited') || - // Un-reblog from following page - (queryKey[1].page === 'Following' && - theParams.payload.property === 'reblogged' && - theParams.payload.currentValue === true) + (queryKey[1].page === 'Favourites' && theParams.payload.property === 'favourited') ) { queryClient.invalidateQueries(queryKey) - } else if ( - theParams.payload.property === 'reblogged' && - queryKey[1].page !== 'Following' - ) { - // When reblogged, update cache of following page - const tempQueryKey: QueryKeyTimeline = [ - 'Timeline', - { page: 'Following' } - ] - queryClient.invalidateQueries(tempQueryKey) } else if (theParams.payload.property === 'favourited') { // When favourited, update favourited page - const tempQueryKey: QueryKeyTimeline = [ - 'Timeline', - { page: 'Favourites' } - ] + const tempQueryKey: QueryKeyTimeline = ['Timeline', { page: 'Favourites' }] queryClient.invalidateQueries(tempQueryKey) } else if (theParams.payload.property === 'bookmarked') { // When bookmarked, update bookmark page - const tempQueryKey: QueryKeyTimeline = [ - 'Timeline', - { page: 'Bookmarks' } - ] + const tempQueryKey: QueryKeyTimeline = ['Timeline', { page: 'Bookmarks' }] queryClient.invalidateQueries(tempQueryKey) } }, @@ -91,9 +69,7 @@ const TimelineActions: React.FC = ({ theme, type: 'error', message: t('common:message.error.message', { - function: t( - `shared.actions.${correctParam.payload.property}.function` - ) + function: t(`shared.actions.${correctParam.payload.property}.function`) }), ...(err.status && typeof err.status === 'number' && @@ -182,11 +158,7 @@ const TimelineActions: React.FC = ({ const childrenReply = useMemo( () => ( <> - + {status.replies_count > 0 ? ( = ({ = ({ const color = (state: boolean) => (state ? colors.red : colors.secondary) return ( <> - + {status.favourites_count > 0 ? ( = ({ const childrenBookmark = useMemo(() => { const color = (state: boolean) => (state ? colors.yellow : colors.secondary) return ( - + ) }, [status.bookmarked]) return ( = ({ = ({ onPress={onPressReblog} children={childrenReblog} disabled={ - status.visibility === 'direct' || - (status.visibility === 'private' && !ownAccount) + status.visibility === 'direct' || (status.visibility === 'private' && !ownAccount) } /> = ({ > = ({ } else { dispatch(updateStoreReview(1)) } - const queryKey: QueryKeyTimeline = ['Timeline', { page: 'Following' }] - queryClient.invalidateQueries(queryKey) switch (params?.type) { case 'edit':