Skip to content

Commit

Permalink
Change behavior of block button on profile
Browse files Browse the repository at this point in the history
  • Loading branch information
duogenesis committed Oct 29, 2023
1 parent 179648b commit 0b853ce
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions components/prospect-profile-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ const SeeQAndAButton = ({navigation, personId, name, countAnswers}) => {
);
};

const BlockButton = ({name, personId, isBlocked}) => {
const BlockButton = ({navigation, name, personId, isBlocked}) => {
const [isLoading, setIsLoading] = useState(false);
const [isBlockedState, setIsBlockedState] = useState(false);

Expand All @@ -300,6 +300,9 @@ const BlockButton = ({name, personId, isBlocked}) => {
if (await setBlocked(personId, nextIsBlockedState)) {
setIsBlockedState(nextIsBlockedState);
setIsLoading(false);
if (nextIsBlockedState) {
navigation.popToTop();
}
}
}, [isLoading, isBlockedState, personId]);

Expand All @@ -324,6 +327,7 @@ const BlockButton = ({name, personId, isBlocked}) => {
style={{
color: '#777',
overflow: 'hidden',
textAlign: 'center',
}}
>
{name === undefined ? '...' : text}
Expand Down Expand Up @@ -751,7 +755,12 @@ const Body = ({
name={data?.name}
countAnswers={data?.count_answers}
/>
<BlockButton name={data?.name} personId={personId} isBlocked={data?.is_blocked} />
<BlockButton
navigation={navigation}
name={data?.name}
personId={personId}
isBlocked={data?.is_blocked}
/>
</View>
</>
);
Expand Down

0 comments on commit 0b853ce

Please sign in to comment.