diff --git a/src/App.vue b/src/App.vue index 411c55e7be8..b8b28e7a4d7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -47,6 +47,7 @@ import Router from './router/router.ts' import BrowserStorage from './services/BrowserStorage.js' import { EventBus } from './services/EventBus.ts' import { leaveConversationSync } from './services/participantsService.js' +import { useActorStore } from './stores/actor.ts' import { useCallViewStore } from './stores/callView.ts' import { useFederationStore } from './stores/federation.ts' import { useSidebarStore } from './stores/sidebar.ts' @@ -80,6 +81,7 @@ export default { federationStore: useFederationStore(), callViewStore: useCallViewStore(), sidebarStore: useSidebarStore(), + actorStore: useActorStore(), } }, @@ -122,7 +124,7 @@ export default { }, getUserId() { - return this.$store.getters.getUserId() + return this.actorStore.userId }, isSendingMessages() { @@ -323,7 +325,7 @@ export default { const payload = { token: params.token, - participantIdentifier: this.$store.getters.getParticipantIdentifier(), + participantIdentifier: this.actorStore.participantIdentifier, flags, silent: true, recordingConsent: this.recordingConsentGiven, @@ -372,7 +374,7 @@ export default { if (!getCurrentUser()) { // Set the current actor/participant for guests const conversation = this.$store.getters.conversation(this.token) - this.$store.dispatch('setCurrentParticipant', conversation) + this.actorStore.setCurrentParticipant(conversation) } }) @@ -440,14 +442,6 @@ export default { }) } }) - - if (getCurrentUser()) { - console.debug('Setting current user') - this.$store.dispatch('setCurrentUser', getCurrentUser()) - this.$store.dispatch('getCurrentUserTeams') - } else { - console.debug('Can not set current user because it\'s a guest') - } }, async mounted() { diff --git a/src/FilesSidebarTabApp.vue b/src/FilesSidebarTabApp.vue index 71978a6acd4..be6b3ccb85c 100644 --- a/src/FilesSidebarTabApp.vue +++ b/src/FilesSidebarTabApp.vue @@ -40,6 +40,7 @@ import { getFileConversation } from './services/filesIntegrationServices.js' import { leaveConversationSync, } from './services/participantsService.js' +import { useActorStore } from './stores/actor.ts' import { checkBrowser } from './utils/browserCheck.ts' import CancelableRequest from './utils/cancelableRequest.js' import { signalingKill } from './utils/webrtc/index.js' @@ -62,6 +63,7 @@ export default { setup() { return { isLeavingAfterSessionIssue: useSessionIssueHandler(), + actorStore: useActorStore(), } }, @@ -142,7 +144,7 @@ export default { }, beforeMount() { - this.$store.dispatch('setCurrentUser', getCurrentUser()) + this.actorStore.setCurrentUser(getCurrentUser()) window.addEventListener('unload', () => { console.info('Navigating away, leaving conversation') diff --git a/src/PublicShareAuthSidebar.vue b/src/PublicShareAuthSidebar.vue index a03fbb04895..ce8b5cc0bff 100644 --- a/src/PublicShareAuthSidebar.vue +++ b/src/PublicShareAuthSidebar.vue @@ -43,6 +43,7 @@ import { leaveConversationSync, setGuestUserName, } from './services/participantsService.js' +import { useActorStore } from './stores/actor.ts' import { signalingKill } from './utils/webrtc/index.js' export default { @@ -65,6 +66,7 @@ export default { return { isLeavingAfterSessionIssue: useSessionIssueHandler(), + actorStore: useActorStore(), } }, @@ -127,9 +129,9 @@ export default { const guestNickname = getGuestNickname() if (currentUser) { - this.$store.dispatch('setCurrentUser', currentUser) + this.actorStore.setCurrentUser(currentUser) } else if (guestNickname) { - this.$store.dispatch('setDisplayName', guestNickname) + this.actorStore.setDisplayName(guestNickname) } else { subscribe('talk:guest-name:added', this.showGuestMediaSettings) } @@ -183,12 +185,12 @@ export default { // Although the current participant is automatically added to // the participants store it must be explicitly set in the // actors store. - if (!this.$store.getters.getUserId()) { + if (!this.actorStore.userId) { // Set the current actor/participant for guests const conversation = this.$store.getters.conversation(this.token) // Setting a guest only uses "sessionId" and "participantType". - this.$store.dispatch('setCurrentParticipant', conversation) + this.actorStore.setCurrentParticipant(conversation) } } catch (exception) { window.clearInterval(this.fetchCurrentConversationIntervalId) diff --git a/src/PublicShareSidebar.vue b/src/PublicShareSidebar.vue index 70277d42ac7..f5a2d1fb931 100644 --- a/src/PublicShareSidebar.vue +++ b/src/PublicShareSidebar.vue @@ -58,6 +58,7 @@ import { getPublicShareConversationData } from './services/filesIntegrationServi import { leaveConversationSync, } from './services/participantsService.js' +import { useActorStore } from './stores/actor.ts' import { checkBrowser } from './utils/browserCheck.ts' import { signalingKill } from './utils/webrtc/index.js' @@ -97,6 +98,7 @@ export default { return { isInCall: useIsInCall(), isLeavingAfterSessionIssue: useSessionIssueHandler(), + actorStore: useActorStore(), } }, @@ -223,7 +225,7 @@ export default { // signaling server will retry the connection again and again, // so at some point the anonymous user will have been overriden // with the current user and the connection will succeed. - this.$store.dispatch('setCurrentUser', { + this.actorStore.setCurrentUser({ uid: data.userId, displayName: data.displayName, }) @@ -241,12 +243,12 @@ export default { // Although the current participant is automatically added to // the participants store it must be explicitly set in the // actors store. - if (!this.$store.getters.getUserId()) { + if (!this.actorStore.userId) { // Set the current actor/participant for guests const conversation = this.$store.getters.conversation(this.token) // Setting a guest only uses "sessionId" and "participantType". - this.$store.dispatch('setCurrentParticipant', conversation) + this.actorStore.setCurrentParticipant(conversation) } } catch (exception) { window.clearInterval(this.fetchCurrentConversationIntervalId) diff --git a/src/components/CallView/Grid/Grid.vue b/src/components/CallView/Grid/Grid.vue index 22f7cda8abc..57ecaa8ec6f 100644 --- a/src/components/CallView/Grid/Grid.vue +++ b/src/components/CallView/Grid/Grid.vue @@ -164,6 +164,7 @@ import LocalVideo from '../shared/LocalVideo.vue' import VideoBottomBar from '../shared/VideoBottomBar.vue' import VideoVue from '../shared/VideoVue.vue' import { ATTENDEE, PARTICIPANT } from '../../../constants.ts' +import { useActorStore } from '../../../stores/actor.ts' import { useCallViewStore } from '../../../stores/callView.ts' import { placeholderImage, placeholderModel, placeholderName, placeholderSharedData } from './gridPlaceholders.ts' @@ -269,6 +270,7 @@ export default { videosCap, videosCapEnforced, callViewStore: useCallViewStore(), + actorStore: useActorStore(), } }, @@ -502,7 +504,7 @@ export default { }, isGuestNonModerator() { - return this.$store.getters.getActorType() === ATTENDEE.ACTOR_TYPE.GUESTS + return this.actorStore.isActorGuest && this.$store.getters.conversation(this.token).participantType !== PARTICIPANT.TYPE.GUEST_MODERATOR }, diff --git a/src/components/CallView/shared/LocalVideo.vue b/src/components/CallView/shared/LocalVideo.vue index 312ccb7569f..2e5f9f3dd45 100644 --- a/src/components/CallView/shared/LocalVideo.vue +++ b/src/components/CallView/shared/LocalVideo.vue @@ -41,7 +41,7 @@ { let testStoreConfig let componentProps let conversationProps + let actorStore const audioIndicatorAriaLabels = [t('spreed', 'Mute'), t('spreed', 'Muted')] const videoIndicatorAriaLabels = [t('spreed', 'Disable video'), t('spreed', 'Enable video')] @@ -47,6 +49,7 @@ describe('VideoBottomBar.vue', () => { localVue.use(Vuex) setActivePinia(createPinia()) callViewStore = useCallViewStore() + actorStore = useActorStore() conversationProps = { token: TOKEN, @@ -83,7 +86,7 @@ describe('VideoBottomBar.vue', () => { testStoreConfig = cloneDeep(storeConfig) testStoreConfig.modules.conversationsStore.getters.conversation = jest.fn().mockReturnValue((token) => conversationProps) - testStoreConfig.modules.actorStore.getters.getUserId = jest.fn().mockReturnValue(() => USER_ID) + actorStore.userId = USER_ID store = new Store(testStoreConfig) }) diff --git a/src/components/CallView/shared/VideoBottomBar.vue b/src/components/CallView/shared/VideoBottomBar.vue index 687d1e2ed69..cc9da624103 100644 --- a/src/components/CallView/shared/VideoBottomBar.vue +++ b/src/components/CallView/shared/VideoBottomBar.vue @@ -101,6 +101,7 @@ import VideoIcon from 'vue-material-design-icons/Video.vue' import VideoOff from 'vue-material-design-icons/VideoOff.vue' import TransitionWrapper from '../../UIShared/TransitionWrapper.vue' import { PARTICIPANT } from '../../../constants.ts' +import { useActorStore } from '../../../stores/actor.ts' import { useCallViewStore } from '../../../stores/callView.ts' import { ConnectionState } from '../../../utils/webrtc/models/CallParticipantModel.js' @@ -186,6 +187,7 @@ export default { setup() { return { callViewStore: useCallViewStore(), + actorStore: useActorStore(), } }, @@ -265,7 +267,7 @@ export default { // Moderator rights participantType() { return this.$store.getters.conversation(this.token)?.participantType - || (this.$store.getters.getUserId() !== null + || (this.actorStore.isLoggedIn ? PARTICIPANT.TYPE.USER : PARTICIPANT.TYPE.GUEST) }, diff --git a/src/components/ChatView.vue b/src/components/ChatView.vue index 25ca0dac426..6b68e4a2f02 100644 --- a/src/components/ChatView.vue +++ b/src/components/ChatView.vue @@ -71,6 +71,7 @@ import TransitionWrapper from './UIShared/TransitionWrapper.vue' import { CONVERSATION, PARTICIPANT } from '../constants.ts' import { getTalkConfig } from '../services/CapabilitiesManager.ts' import { EventBus } from '../services/EventBus.ts' +import { useActorStore } from '../stores/actor.ts' import { useChatExtrasStore } from '../stores/chatExtras.js' export default { @@ -108,6 +109,7 @@ export default { provide('chatView:isSidebar', props.isSidebar) return { chatExtrasStore: useChatExtrasStore(), + actorStore: useActorStore(), } }, @@ -120,16 +122,15 @@ export default { computed: { isGuest() { - return this.$store.getters.isActorGuest() + return this.actorStore.isActorGuest }, isGuestWithoutDisplayName() { - const userName = this.$store.getters.getDisplayName() - return !userName && this.isGuest + return this.isGuest && !this.actorStore.displayName }, canUploadFiles() { - return getTalkConfig(this.token, 'attachments', 'allowed') && this.$store.getters.getUserId() + return getTalkConfig(this.token, 'attachments', 'allowed') && this.actorStore.userId && this.$store.getters.getAttachmentFolderFreeSpace() !== 0 && (this.conversation.permissions & PARTICIPANT.PERMISSIONS.CHAT) && !this.conversation.remoteServer // no attachments support in federated conversations diff --git a/src/components/ConversationSettings/ConversationSettingsDialog.vue b/src/components/ConversationSettings/ConversationSettingsDialog.vue index b2005cff13e..37c1057881d 100644 --- a/src/components/ConversationSettings/ConversationSettingsDialog.vue +++ b/src/components/ConversationSettings/ConversationSettingsDialog.vue @@ -131,6 +131,7 @@ import RecordingConsentSettings from './RecordingConsentSettings.vue' import SipSettings from './SipSettings.vue' import { CALL, CONFIG, CONVERSATION, PARTICIPANT } from '../../constants.ts' import { getTalkConfig, hasTalkFeature } from '../../services/CapabilitiesManager.ts' +import { useActorStore } from '../../stores/actor.ts' import { useSettingsStore } from '../../stores/settings.js' const supportsArchive = hasTalkFeature('local', 'archived-conversations-v2') @@ -167,6 +168,7 @@ export default { supportsArchive, settingsStore, meetingHeader, + actorStore: useActorStore(), } }, @@ -195,7 +197,7 @@ export default { }, isGuest() { - return this.$store.getters.isActorGuest() + return this.actorStore.isActorGuest }, token() { diff --git a/src/components/Dashboard/TalkDashboard.vue b/src/components/Dashboard/TalkDashboard.vue index 5360f42d72e..aa14d6fde8a 100644 --- a/src/components/Dashboard/TalkDashboard.vue +++ b/src/components/Dashboard/TalkDashboard.vue @@ -31,6 +31,7 @@ import { useStore } from '../../composables/useStore.js' import { CONVERSATION } from '../../constants.ts' import { getTalkConfig, hasTalkFeature } from '../../services/CapabilitiesManager.ts' import { EventBus } from '../../services/EventBus.ts' +import { useActorStore } from '../../stores/actor.ts' import { useDashboardStore } from '../../stores/dashboard.ts' import { hasUnreadMentions } from '../../utils/conversation.ts' import { copyConversationLinkToClipboard } from '../../utils/handleUrl.ts' @@ -46,6 +47,7 @@ const isDirectionRTL = isRTL() const store = useStore() const router = useRouter() const dashboardStore = useDashboardStore() +const actorStore = useActorStore() const forwardScrollable = ref(false) const backwardScrollable = ref(false) const eventCardsWrapper = ref(null) @@ -166,7 +168,7 @@ function scrollEventCards({ direction }: { direction: 'backward' | 'forward' })