From 8eb67f469cf631fde8f1aa55d3ab1d56d11d45b9 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sat, 23 Mar 2024 12:26:01 +0800 Subject: [PATCH] Add Enable/Disable notifications/boosts for accounts --- src/components/account-info.jsx | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/components/account-info.jsx b/src/components/account-info.jsx index bc72890d..0128be01 100644 --- a/src/components/account-info.jsx +++ b/src/components/account-info.jsx @@ -1029,6 +1029,70 @@ function RelatedActions({ {privateNote ? 'Edit private note' : 'Add private note'} + {following && !!relationship && ( + <> + { + setRelationshipUIState('loading'); + (async () => { + try { + const rel = await currentMasto.v1.accounts + .$select(accountID.current) + .follow({ + notify: !notifying, + }); + if (rel) setRelationship(rel); + setRelationshipUIState('default'); + showToast( + rel.notifying + ? `Notifications enabled for @${username}'s posts.` + : ` Notifications disabled for @${username}'s posts.`, + ); + } catch (e) { + alert(e); + setRelationshipUIState('error'); + } + })(); + }} + > + + + {notifying + ? 'Disable notifications' + : 'Enable notifications'} + + + { + setRelationshipUIState('loading'); + (async () => { + try { + const rel = await currentMasto.v1.accounts + .$select(accountID.current) + .follow({ + reblogs: !showingReblogs, + }); + if (rel) setRelationship(rel); + setRelationshipUIState('default'); + showToast( + rel.showingReblogs + ? `Boosts from @${username} disabled.` + : `Boosts from @${username} enabled.`, + ); + } catch (e) { + alert(e); + setRelationshipUIState('error'); + } + })(); + }} + > + + + {showingReblogs ? 'Disable boosts' : 'Enable boosts'} + + + + )} {/* Add/remove from lists is only possible if following the account */} {following && (