From f05267b216f0f111b8e1d141f2d656c15fce5044 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 2 Oct 2023 17:51:36 +0800 Subject: [PATCH] MVP implementation of listing muted/blocked users --- src/components/account-info.jsx | 6 ++++ src/components/generic-accounts.jsx | 9 +++++ src/components/icon.jsx | 2 ++ src/components/nav-menu.jsx | 54 +++++++++++++++++++++++++++-- src/utils/states.js | 4 +++ 5 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/components/account-info.jsx b/src/components/account-info.jsx index 3f3abeba..6c719583 100644 --- a/src/components/account-info.jsx +++ b/src/components/account-info.jsx @@ -906,6 +906,8 @@ function RelatedActions({ info, instance, authenticated, standalone }) { setRelationship(newRelationship); setRelationshipUIState('default'); showToast(`Unmuted @${username}`); + states.reloadGenericAccounts.id = 'mute'; + states.reloadGenericAccounts.counter++; } catch (e) { console.error(e); setRelationshipUIState('error'); @@ -957,6 +959,8 @@ function RelatedActions({ info, instance, authenticated, standalone }) { showToast( `Muted @${username} for ${MUTE_DURATIONS_LABELS[duration]}`, ); + states.reloadGenericAccounts.id = 'mute'; + states.reloadGenericAccounts.counter++; } catch (e) { console.error(e); setRelationshipUIState('error'); @@ -1007,6 +1011,8 @@ function RelatedActions({ info, instance, authenticated, standalone }) { setRelationshipUIState('default'); showToast(`Blocked @${username}`); } + states.reloadGenericAccounts.id = 'block'; + states.reloadGenericAccounts.counter++; } catch (e) { console.error(e); setRelationshipUIState('error'); diff --git a/src/components/generic-accounts.jsx b/src/components/generic-accounts.jsx index ca269ed1..fbcb12aa 100644 --- a/src/components/generic-accounts.jsx +++ b/src/components/generic-accounts.jsx @@ -21,6 +21,7 @@ export default function GenericAccounts({ onClose = () => {} }) { } const { + id, heading, fetchAccounts, accounts: staticAccounts, @@ -60,6 +61,14 @@ export default function GenericAccounts({ onClose = () => {} }) { } }, [staticAccounts, fetchAccounts]); + useEffect(() => { + // reloadGenericAccounts contains value like {id: 'mute', counter: 1} + // We only need to reload if the id matches + if (snapStates.reloadGenericAccounts?.id === id) { + loadAccounts(true); + } + }, [snapStates.reloadGenericAccounts.counter]); + return (