From 300fe0981cf51b3e03d217691ac6ee099f64f756 Mon Sep 17 00:00:00 2001 From: Robert Long Date: Thu, 8 Oct 2020 13:43:05 -0700 Subject: [PATCH] Add Mute All button functionality --- src/react-components/room/PeopleSidebar.js | 14 +++++++---- src/react-components/room/PeopleSidebar.scss | 8 +++++++ .../room/PeopleSidebarContainer.js | 24 +++++++++++++++++-- src/react-components/ui-root.js | 1 + 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/react-components/room/PeopleSidebar.js b/src/react-components/room/PeopleSidebar.js index 0a29de6f55..4fb0e6c171 100644 --- a/src/react-components/room/PeopleSidebar.js +++ b/src/react-components/room/PeopleSidebar.js @@ -94,7 +94,7 @@ function getLabel(person) { )} and ${getVoiceLabel(person.micPresence)} ${getDeviceLabel(person.context)}.`; } -export function PeopleSidebar({ people, onSelectPerson, onClose }) { +export function PeopleSidebar({ people, onSelectPerson, onClose, showMuteAll, onMuteAll }) { return ( } afterTitle={ - - Mute All - + showMuteAll ? ( + + Mute All + + ) : ( + undefined + ) } > @@ -140,6 +144,8 @@ export function PeopleSidebar({ people, onSelectPerson, onClose }) { PeopleSidebar.propTypes = { people: PropTypes.array, onSelectPerson: PropTypes.func, + showMuteAll: PropTypes.bool, + onMuteAll: PropTypes.func, onClose: PropTypes.func }; diff --git a/src/react-components/room/PeopleSidebar.scss b/src/react-components/room/PeopleSidebar.scss index 0114241389..0d0b1fda60 100644 --- a/src/react-components/room/PeopleSidebar.scss +++ b/src/react-components/room/PeopleSidebar.scss @@ -26,4 +26,12 @@ display: flex; flex: 1; justify-content: flex-end; +} + +:local(.close-button) { + margin-left: 16px; +} + +:local(.mute-all-button) { + margin-right: 16px; } \ No newline at end of file diff --git a/src/react-components/room/PeopleSidebarContainer.js b/src/react-components/room/PeopleSidebarContainer.js index 97190854c9..89cbf75740 100644 --- a/src/react-components/room/PeopleSidebarContainer.js +++ b/src/react-components/room/PeopleSidebarContainer.js @@ -37,7 +37,7 @@ function usePeopleList(presences, mySessionId, micUpdateFrequency = 500) { return people; } -export function PeopleSidebarContainer({ history, presences, mySessionId, onOpenAvatarSettings, onClose }) { +export function PeopleSidebarContainer({ hubChannel, history, presences, mySessionId, onOpenAvatarSettings, onClose }) { const people = usePeopleList(presences, mySessionId); // TODO: Dont use state routes for profiles @@ -52,10 +52,30 @@ export function PeopleSidebarContainer({ history, presences, mySessionId, onOpen [history, mySessionId, onOpenAvatarSettings] ); - return ; + const onMuteAll = useCallback( + () => { + for (const person of people) { + if (person.presence === "room" && person.permissions && !person.permissions.mute_users) { + hubChannel.mute(person.id); + } + } + }, + [people, hubChannel] + ); + + return ( + + ); } PeopleSidebarContainer.propTypes = { + hubChannel: PropTypes.object.isRequired, history: PropTypes.object.isRequired, onOpenAvatarSettings: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired, diff --git a/src/react-components/ui-root.js b/src/react-components/ui-root.js index d02252203d..7ddf3587a1 100644 --- a/src/react-components/ui-root.js +++ b/src/react-components/ui-root.js @@ -1869,6 +1869,7 @@ class UIRoot extends Component { )} {this.state.sidebarId === "people" && (