Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 2 additions & 18 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ import {
joinConversation,
leaveConversationSync,
} from './services/participantsService'
import { PARTICIPANT } from './constants'
import {
signalingKill,
} from './utils/webrtc/index'
import { emit } from '@nextcloud/event-bus'
import browserCheck from './mixins/browserCheck'
import duplicateSessionHandler from './mixins/duplicateSessionHandler'
import isInCall from './mixins/isInCall'
import participant from './mixins/participant'
import talkHashCheck from './mixins/talkHashCheck'
import { generateUrl } from '@nextcloud/router'
import UploadEditor from './components/UploadEditor'
Expand All @@ -84,6 +84,7 @@ export default {
talkHashCheck,
duplicateSessionHandler,
isInCall,
participant,
],

data() {
Expand All @@ -107,23 +108,6 @@ export default {
return this.$store.getters.getUserId()
},

participant() {
if (typeof this.token === 'undefined') {
return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
}

const participantIndex = this.$store.getters.getParticipantIndex(this.token, this.$store.getters.getParticipantIdentifier())
if (participantIndex !== -1) {
return this.$store.getters.getParticipant(this.token, participantIndex)
}

return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
},

warnLeaving() {
return !this.isLeavingAfterSessionConflict && this.isInCall
},
Expand Down
14 changes: 2 additions & 12 deletions src/FilesSidebarCallViewApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
</template>

<script>
import { PARTICIPANT } from './constants'
import CallView from './components/CallView/CallView'
import PreventUnload from 'vue-prevent-unload'
import duplicateSessionHandler from './mixins/duplicateSessionHandler'
import isInCall from './mixins/isInCall'
import participant from './mixins/participant'
import talkHashCheck from './mixins/talkHashCheck'
import '@nextcloud/dialogs/styles/toast.scss'

Expand All @@ -51,6 +51,7 @@ export default {
mixins: [
duplicateSessionHandler,
isInCall,
participant,
talkHashCheck,
],

Expand Down Expand Up @@ -106,17 +107,6 @@ export default {
return this.isInCall
},

participant() {
const participantIndex = this.$store.getters.getParticipantIndex(this.token, this.$store.getters.getParticipantIdentifier())
if (participantIndex === -1) {
return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
}

return this.$store.getters.getParticipant(this.token, participantIndex)
},

warnLeaving() {
return !this.isLeavingAfterSessionConflict && this.showCallView
},
Expand Down
14 changes: 2 additions & 12 deletions src/PublicShareSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import { loadState } from '@nextcloud/initial-state'
import CallView from './components/CallView/CallView'
import ChatView from './components/ChatView'
import CallButton from './components/TopBar/CallButton'
import { PARTICIPANT } from './constants'
import { EventBus } from './services/EventBus'
import { fetchConversation } from './services/conversationsService'
import { getPublicShareConversationData } from './services/filesIntegrationServices'
Expand All @@ -61,6 +60,7 @@ import { signalingKill } from './utils/webrtc/index'
import browserCheck from './mixins/browserCheck'
import duplicateSessionHandler from './mixins/duplicateSessionHandler'
import isInCall from './mixins/isInCall'
import participant from './mixins/participant'
import talkHashCheck from './mixins/talkHashCheck'
import '@nextcloud/dialogs/styles/toast.scss'

Expand All @@ -79,6 +79,7 @@ export default {
browserCheck,
duplicateSessionHandler,
isInCall,
participant,
talkHashCheck,
],

Expand Down Expand Up @@ -114,17 +115,6 @@ export default {
return this.state.isOpen
},

participant() {
const participantIndex = this.$store.getters.getParticipantIndex(this.token, this.$store.getters.getParticipantIdentifier())
if (participantIndex === -1) {
return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
}

return this.$store.getters.getParticipant(this.token, participantIndex)
},

warnLeaving() {
return !this.isLeavingAfterSessionConflict && this.isInCall
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ import {
} from '../../../services/conversationsService'
import { generateUrl } from '@nextcloud/router'
import PasswordProtect from './PasswordProtect/PasswordProtect'
import { PARTICIPANT } from '../../../constants'
import isInCall from '../../../mixins/isInCall'
import participant from '../../../mixins/participant'
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip'

export default {
Expand All @@ -154,6 +155,11 @@ export default {
Plus,
},

mixins: [
isInCall,
participant,
],

data() {
return {
modal: false,
Expand Down Expand Up @@ -187,27 +193,6 @@ export default {
selectedParticipants() {
return this.$store.getters.selectedParticipants
},

participant() {
if (this.$store.getters.getToken()) {
return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
}

const participantIndex = this.$store.getters.getParticipantIndex(this.$store.getters.getToken(), this.$store.getters.getParticipantIdentifier())
if (participantIndex !== -1) {
return this.$store.getters.getParticipant(this.$store.getters.getToken(), participantIndex)
}

return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
},

isInCall() {
return this.participant.inCall !== PARTICIPANT.CALL_FLAG.DISCONNECTED
},
},

methods: {
Expand Down
17 changes: 6 additions & 11 deletions src/components/MessagesList/MessagesGroup/Message/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import FilePreview from './MessagePart/FilePreview'
import Mention from './MessagePart/Mention'
import RichText from '@juliushaertl/vue-richtext'
import Quote from '../../../Quote'
import participant from '../../../../mixins/participant'
import { EventBus } from '../../../../services/EventBus'
import emojiRegex from 'emoji-regex'
import { PARTICIPANT, CONVERSATION } from '../../../../constants'
Expand All @@ -104,6 +105,11 @@ export default {
Quote,
RichText,
},

mixins: [
participant,
],

inheritAttrs: false,

props: {
Expand Down Expand Up @@ -246,17 +252,6 @@ export default {
return this.$store.getters.conversation(this.token)
},

participant() {
const participantIndex = this.$store.getters.getParticipantIndex(this.token, this.$store.getters.getParticipantIdentifier())
if (participantIndex !== -1) {
return this.$store.getters.getParticipant(this.token, participantIndex)
}

return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
},

messagesList() {
return this.$store.getters.messagesList(this.token)
},
Expand Down
15 changes: 2 additions & 13 deletions src/components/TopBar/CallButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import { CONVERSATION, PARTICIPANT, WEBINAR } from '../../constants'
import browserCheck from '../../mixins/browserCheck'
import isInCall from '../../mixins/isInCall'
import participant from '../../mixins/participant'
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip'
import { emit } from '@nextcloud/event-bus'

Expand All @@ -65,6 +66,7 @@ export default {
mixins: [
browserCheck,
isInCall,
participant,
],

data() {
Expand Down Expand Up @@ -95,19 +97,6 @@ export default {
}
},

participant() {
const participantIndex = this.$store.getters.getParticipantIndex(this.token, this.$store.getters.getParticipantIdentifier())
if (participantIndex !== -1) {
console.debug('Current participant found')
return this.$store.getters.getParticipant(this.token, participantIndex)
}

console.debug('Current participant not found')
return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
},

isBlockedByLobby() {
return this.conversation.lobbyState === WEBINAR.LOBBY.NON_MODERATORS
&& !this.isParticipantTypeModerator(this.conversation.participantType)
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/isInCall.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { EventBus } from '../services/EventBus'
/**
* A mixin to check whether the current session of a user is in a call or not.
*
* Components using this mixin require a "token" property and a "participant" property with, at least, the "inCall" property.
* Components using this mixin require a "participant" property with, at least, the "inCall" property.
*/
export default {

Expand All @@ -38,7 +38,7 @@ export default {

computed: {
isInCall() {
return this.sessionStorageJoinedConversation === this.token
return this.sessionStorageJoinedConversation === this.$store.getters.getToken()
&& this.participant.inCall !== PARTICIPANT.CALL_FLAG.DISCONNECTED
},
},
Expand Down
48 changes: 48 additions & 0 deletions src/mixins/participant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
*
* @copyright Copyright (c) 2020 Vincent Petry <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

import { PARTICIPANT } from '../constants'

/**
* A mixin to check retrieve the current participant object
*/
export default {

computed: {
participant() {
const token = this.$store.getters.getToken()
if (typeof token === 'undefined') {
return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
}

const participantIndex = this.$store.getters.getParticipantIndex(token, this.$store.getters.getParticipantIdentifier())
if (participantIndex === -1) {
return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
}

return this.$store.getters.getParticipant(token, participantIndex)
},
},
}
19 changes: 2 additions & 17 deletions src/views/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import TopBar from '../components/TopBar/TopBar'
import { PARTICIPANT } from '../constants'
import isInLobby from '../mixins/isInLobby'
import isInCall from '../mixins/isInCall'
import participant from '../mixins/participant'

export default {
name: 'MainView',
Expand All @@ -36,6 +37,7 @@ export default {
mixins: [
isInLobby,
isInCall,
participant,
],

props: {
Expand All @@ -50,23 +52,6 @@ export default {
return this.$store.getters.conversation(this.token)
},

participant() {
if (typeof this.token === 'undefined') {
return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
}

const participantIndex = this.$store.getters.getParticipantIndex(this.token, this.$store.getters.getParticipantIdentifier())
if (participantIndex !== -1) {
return this.$store.getters.getParticipant(this.token, participantIndex)
}

return {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}
},

showChatInSidebar() {
return this.isInCall
},
Expand Down