this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

MVP implementation of listing muted/blocked users

+73 -2
+6
src/components/account-info.jsx
··· 906 906 setRelationship(newRelationship); 907 907 setRelationshipUIState('default'); 908 908 showToast(`Unmuted @${username}`); 909 + states.reloadGenericAccounts.id = 'mute'; 910 + states.reloadGenericAccounts.counter++; 909 911 } catch (e) { 910 912 console.error(e); 911 913 setRelationshipUIState('error'); ··· 957 959 showToast( 958 960 `Muted @${username} for ${MUTE_DURATIONS_LABELS[duration]}`, 959 961 ); 962 + states.reloadGenericAccounts.id = 'mute'; 963 + states.reloadGenericAccounts.counter++; 960 964 } catch (e) { 961 965 console.error(e); 962 966 setRelationshipUIState('error'); ··· 1007 1011 setRelationshipUIState('default'); 1008 1012 showToast(`Blocked @${username}`); 1009 1013 } 1014 + states.reloadGenericAccounts.id = 'block'; 1015 + states.reloadGenericAccounts.counter++; 1010 1016 } catch (e) { 1011 1017 console.error(e); 1012 1018 setRelationshipUIState('error');
+9
src/components/generic-accounts.jsx
··· 21 21 } 22 22 23 23 const { 24 + id, 24 25 heading, 25 26 fetchAccounts, 26 27 accounts: staticAccounts, ··· 59 60 loadAccounts(true); 60 61 } 61 62 }, [staticAccounts, fetchAccounts]); 63 + 64 + useEffect(() => { 65 + // reloadGenericAccounts contains value like {id: 'mute', counter: 1} 66 + // We only need to reload if the id matches 67 + if (snapStates.reloadGenericAccounts?.id === id) { 68 + loadAccounts(true); 69 + } 70 + }, [snapStates.reloadGenericAccounts.counter]); 62 71 63 72 return ( 64 73 <div id="generic-accounts-container" class="sheet" tabindex="-1">
+2
src/components/icon.jsx
··· 99 99 'account-edit': () => import('@iconify-icons/mingcute/user-edit-line'), 100 100 'account-warning': () => import('@iconify-icons/mingcute/user-warning-line'), 101 101 keyboard: () => import('@iconify-icons/mingcute/keyboard-line'), 102 + 'mute-user': () => import('@iconify-icons/mingcute/user-hide-line'), 103 + 'block-user': () => import('@iconify-icons/mingcute/user-security-line'), 102 104 }; 103 105 104 106 function Icon({
+52 -2
src/components/nav-menu.jsx
··· 1 1 import './nav-menu.css'; 2 2 3 - import { ControlledMenu, MenuDivider, MenuItem } from '@szhsin/react-menu'; 3 + import { 4 + ControlledMenu, 5 + Menu, 6 + MenuDivider, 7 + MenuItem, 8 + } from '@szhsin/react-menu'; 4 9 import { useEffect, useRef, useState } from 'preact/hooks'; 5 10 import { useLongPress } from 'use-long-press'; 6 11 import { useSnapshot } from 'valtio'; ··· 16 21 17 22 function NavMenu(props) { 18 23 const snapStates = useSnapshot(states); 19 - const { instance, authenticated } = api(); 24 + const { masto, instance, authenticated } = api(); 20 25 21 26 const [currentAccount, setCurrentAccount] = useState(); 22 27 const [moreThanOneAccount, setMoreThanOneAccount] = useState(false); ··· 59 64 snapStates.settings.shortcutsViewMode === 'tab-menu-bar' ? 50 : 0, 60 65 0, 61 66 ]); 67 + 68 + const mutesIterator = useRef(); 69 + async function fetchMutes(firstLoad) { 70 + if (firstLoad || !mutesIterator.current) { 71 + mutesIterator.current = masto.v1.mutes.list({ 72 + limit: 80, 73 + }); 74 + } 75 + const results = await mutesIterator.current.next(); 76 + return results; 77 + } 78 + 79 + const blocksIterator = useRef(); 80 + async function fetchBlocks(firstLoad) { 81 + if (firstLoad || !blocksIterator.current) { 82 + blocksIterator.current = masto.v1.blocks.list({ 83 + limit: 80, 84 + }); 85 + } 86 + const results = await blocksIterator.current.next(); 87 + return results; 88 + } 62 89 63 90 return ( 64 91 <> ··· 203 230 }} 204 231 > 205 232 <Icon icon="group" size="l" /> <span>Accounts&hellip;</span> 233 + </MenuItem> 234 + <MenuItem 235 + onClick={() => { 236 + states.showGenericAccounts = { 237 + id: 'mute', 238 + heading: 'Muted users', 239 + fetchAccounts: fetchMutes, 240 + }; 241 + }} 242 + > 243 + <Icon icon="mute-user" size="l" /> Muted users&hellip; 244 + </MenuItem> 245 + <MenuItem 246 + onClick={() => { 247 + states.showGenericAccounts = { 248 + id: 'block', 249 + heading: 'Blocked users', 250 + fetchAccounts: fetchBlocks, 251 + }; 252 + }} 253 + > 254 + <Icon icon="block-user" size="l" /> 255 + Blocked users&hellip; 206 256 </MenuItem> 207 257 <MenuItem 208 258 onClick={() => {
+4
src/utils/states.js
··· 24 24 notificationsLastFetchTime: null, 25 25 accounts: {}, 26 26 reloadStatusPage: 0, 27 + reloadGenericAccounts: { 28 + id: null, 29 + counter: 0, 30 + }, 27 31 spoilers: {}, 28 32 scrollPositions: {}, 29 33 unfurledLinks: {},