From 67e809a85b625d13f1a0c5a8995d007bbcf4a37f Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Wed, 26 May 2021 14:56:40 -0700 Subject: Set id to '', Remove drawer btn after remove tag --- src/components/profile/MomentMoreInfoDrawer.tsx | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/components/profile') diff --git a/src/components/profile/MomentMoreInfoDrawer.tsx b/src/components/profile/MomentMoreInfoDrawer.tsx index 3f8707e8..1265497e 100644 --- a/src/components/profile/MomentMoreInfoDrawer.tsx +++ b/src/components/profile/MomentMoreInfoDrawer.tsx @@ -116,26 +116,26 @@ const MomentMoreInfoDrawer: React.FC = (props) => { * Update bottom drawer options to contain/not contain 'remove tag' option */ useEffect(() => { - const setupBottomDrawer = async () => { + const setupBottomDrawer = () => { const present = drawerButtons.findIndex( (button) => button[0] === MomentDrawerOptions.RemoveTag, ); - if (momentTagId !== '') { - if (present === -1) { - const localDrawerButtons = drawerButtons; - localDrawerButtons.push([ - MomentDrawerOptions.RemoveTag, - handleRemoveTag, - ]); - setDrawerButtons(localDrawerButtons); - } - } else { - if (present !== -1) { - const filteredButtons = drawerButtons.filter( - (button) => button[0] !== MomentDrawerOptions.RemoveTag, - ); - setDrawerButtons(filteredButtons); - } + /* + * If user is not tagged but button is present, remove button from bottom drawer + * If user is tagged but button is not present, add button to bottom drawer + */ + if (momentTagId !== '' && present === -1) { + const localDrawerButtons = drawerButtons; + localDrawerButtons.push([ + MomentDrawerOptions.RemoveTag, + handleRemoveTag, + ]); + setDrawerButtons(localDrawerButtons); + } else if (momentTagId === '' && present !== -1) { + const filteredButtons = drawerButtons.filter( + (button) => button[0] !== MomentDrawerOptions.RemoveTag, + ); + setDrawerButtons(filteredButtons); } }; setupBottomDrawer(); -- cgit v1.2.3-70-g09d2