Skip to content

Commit

Permalink
remove getParticipants mixin from TopBar, redo logic for guest modera…
Browse files Browse the repository at this point in the history
…tors

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Sep 17, 2023
1 parent 00cbbdd commit d17d9df
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
9 changes: 7 additions & 2 deletions src/components/RightSidebar/RightSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,14 @@ export default {
}
},
// Switch tab for guest if he is demoted from moderators
isModeratorOrUser(newValue) {
if (!newValue) {
if (newValue) {
// Fetch participants list if guest was promoted to moderators
this.$nextTick(() => {
emit('guest-promoted', { token: this.token })
})
} else {
// Switch active tab to chat if guest was demoted from moderators
this.activeTab = 'chat'
}
},
Expand Down
18 changes: 2 additions & 16 deletions src/components/TopBar/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ import TopBarMediaControls from './TopBarMediaControls.vue'
import TopBarMenu from './TopBarMenu.vue'
import { CONVERSATION } from '../../constants.js'
import getParticipants from '../../mixins/getParticipants.js'
import isInLobby from '../../mixins/isInLobby.js'
import BrowserStorage from '../../services/BrowserStorage.js'
import { getStatusMessage } from '../../utils/userStatus.js'
import { localCallParticipantModel, localMediaModel } from '../../utils/webrtc/index.js'
Expand Down Expand Up @@ -195,7 +195,7 @@ export default {
mixins: [
richEditor,
getParticipants,
isInLobby,
],
props: {
Expand Down Expand Up @@ -343,18 +343,6 @@ export default {
this.notifyUnreadMessages(null)
}
},
isModeratorOrUser(newValue) {
if (newValue) {
// fetch participants immediately when becomes available
this.cancelableGetParticipants()
}
},
},
beforeMount() {
// Initialises the get participants mixin for participants counter
this.initialiseGetParticipantsMixin()
},
mounted() {
Expand All @@ -372,8 +360,6 @@ export default {
document.removeEventListener('MSFullscreenChange', this.fullScreenChanged, false)
document.removeEventListener('webkitfullscreenchange', this.fullScreenChanged, false)
document.body.classList.remove('has-topbar')
this.stopGetParticipantsMixin()
},
methods: {
Expand Down
6 changes: 6 additions & 0 deletions src/mixins/getParticipants.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/
import debounce from 'debounce'

import { subscribe, unsubscribe } from '@nextcloud/event-bus'

import { EventBus } from '../services/EventBus.js'
import isInLobby from './isInLobby.js'

Expand Down Expand Up @@ -52,12 +54,16 @@ const getParticipants = {
// Then we have to search for another solution. Maybe the room list which we update
// periodically gets a hash of all online sessions?
EventBus.$on('signaling-participant-list-changed', this.debounceUpdateParticipants)

subscribe('guest-promoted', this.onJoinedConversation)
},

stopGetParticipantsMixin() {
EventBus.$off('route-change', this.onRouteChange)
EventBus.$off('joined-conversation', this.onJoinedConversation)
EventBus.$off('signaling-participant-list-changed', this.debounceUpdateParticipants)

unsubscribe('guest-promoted', this.onJoinedConversation)
},

onRouteChange() {
Expand Down
4 changes: 3 additions & 1 deletion src/store/participantsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,9 @@ const actions = {

return response
} catch (exception) {
if (!CancelableRequest.isCancel(exception)) {
if (exception?.response.status === 403) {
context.dispatch('fetchConversation', { token })
} else if (!CancelableRequest.isCancel(exception)) {
console.error(exception)
showError(t('spreed', 'An error occurred while fetching the participants'))
}
Expand Down

0 comments on commit d17d9df

Please sign in to comment.