Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(participants): update participants session status from signaling #12556

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(participants): store signaling sessions metadata and map attende…
…es from participants update

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Jun 25, 2024
commit a20d7d7ef4d5298156c52d1ed7eb874d38776ace
10 changes: 10 additions & 0 deletions src/store/participantsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
import SessionStorage from '../services/SessionStorage.js'
import { talkBroadcastChannel } from '../services/talkBroadcastChannel.js'
import { useGuestNameStore } from '../stores/guestName.js'
import { useSignalingStore } from '../stores/signaling.ts'
import CancelableRequest from '../utils/cancelableRequest.js'

/**
Expand Down Expand Up @@ -687,6 +688,10 @@ const actions = {
}
}

const signalingStore = useSignalingStore()
const unknownSignalingSessions = Object.values(signalingStore.sessions)
.filter(session => !session.attendeeId)

newParticipants.forEach(participant => {
if (context.state.attendees[token]?.[participant.attendeeId]) {
context.dispatch('updateParticipantIfHasChanged', { token, participant, hasUserStatuses })
Expand All @@ -697,6 +702,11 @@ const actions = {
}
}

const session = unknownSignalingSessions.find(session => participant.sessionIds.includes(session.sessionId))
if (session) {
signalingStore.addSignalingSession({ ...session, attendeeId: participant.attendeeId })
}

if (participant.participantType === PARTICIPANT.TYPE.GUEST
|| participant.participantType === PARTICIPANT.TYPE.GUEST_MODERATOR) {
guestNameStore.addGuestName({
Expand Down
44 changes: 44 additions & 0 deletions src/stores/signaling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { defineStore } from 'pinia'
import Vue from 'vue'

import type { Participant } from '../types'

type Session = {
attendeeId: number | undefined,
token: string,
signalingSessionId: string,
sessionId: string | undefined,
}
type State = {
sessions: Record<string, Session>,
}
export const useSignalingStore = defineStore('signaling', {
state: (): State => ({
sessions: {},
}),

getters: {
getSignalingSession: (state) => (signalingSessionId?: string): Session | undefined => {
if (signalingSessionId) {
return state.sessions[signalingSessionId]
}
},
},

actions: {
addSignalingSession(session: Session) {
Vue.set(this.sessions, session.signalingSessionId, session)
},

deleteSignalingSession(signalingSessionId: string) {
if (this.sessions[signalingSessionId]) {
Vue.delete(this.sessions, signalingSessionId)
}
},
},
})