Skip to content

Commit

Permalink
get it working
Browse files Browse the repository at this point in the history
Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
  • Loading branch information
jakobroehrl committed Mar 2, 2021
1 parent d58834d commit f35fd8e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
18 changes: 16 additions & 2 deletions src/components/ChatView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import MessagesList from './MessagesList/MessagesList'
import NewMessageForm from './NewMessageForm/NewMessageForm'
import { processFiles } from '../utils/fileUpload'
import { CONVERSATION } from '../constants'
import { CONVERSATION, PARTICIPANT } from '../constants'
export default {
Expand Down Expand Up @@ -97,12 +97,26 @@ export default {
},
isReadOnly() {
if (this.$store.getters.conversation(this.token)) {
return this.$store.getters.conversation(this.token).readOnly === CONVERSATION.STATE.READ_ONLY
return (this.$store.getters.conversation(this.token).readOnly === CONVERSATION.STATE.READ_ONLY)
|| (this.$store.getters.conversation(this.token).readOnly === CONVERSATION.STATE.WRITE_ONLY_MOD && !this.selfIsModerator)
} else {
return undefined
}
},
currentParticipant() {
return this.$store.getters.conversation(this.token) || {
sessionId: '0',
participantType: this.$store.getters.getUserId() !== null ? PARTICIPANT.TYPE.USER : PARTICIPANT.TYPE.GUEST,
}
},
selfIsModerator() {
return this.currentParticipant.participantType === PARTICIPANT.TYPE.OWNER
|| this.currentParticipant.participantType === PARTICIPANT.TYPE.MODERATOR
|| this.currentParticipant.participantType === PARTICIPANT.TYPE.GUEST_MODERATOR
},
token() {
return this.$store.getters.getToken()
},
Expand Down
17 changes: 11 additions & 6 deletions src/components/ConversationSettings/LockingSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
<h3>{{ t('spreed', 'Limit writing to a conversation') }}</h3>
<p>
<Multiselect id="limit_writing"
v-model="writingConversations"
v-model="writingConversationSelected"
:options="writingConversationOptions"
:placeholder="t('spreed', 'Limit writing to conversations')"
label="label"
track-by="value"
:disabled="isReadOnlyStateLoading"
@input="saveWritingConversations" />
</p>
</div>
Expand All @@ -45,9 +46,9 @@ import { CONVERSATION } from '../../constants'
import Multiselect from '@nextcloud/vue/dist/Components/Multiselect'
const writingConversationOptions = [
{ value: 0, label: t('spreed', 'Everyone can read and write') },
{ value: 1, label: t('spreed', 'Lock conversation') },
{ value: 2, label: t('spreed', 'Only Moderators can write') },
{ value: 0, label: t('spreed', 'Everyone can write') },
{ value: 2, label: t('spreed', 'Only moderators can write') },
{ value: 1, label: t('spreed', 'Read only') },
]
export default {
Expand All @@ -68,7 +69,7 @@ export default {
return {
isReadOnlyStateLoading: false,
writingConversationOptions,
writingConversations: writingConversationOptions[this.isReadOnly],
writingConversationSelected: [],
loadingWritingConversations: false,
}
},
Expand All @@ -83,9 +84,13 @@ export default {
},
},
mounted() {
this.writingConversationSelected = this.writingConversationOptions[this.conversation.readOnly]
},
methods: {
async saveWritingConversations() {
const newReadOnly = this.isReadOnly ? CONVERSATION.STATE.READ_WRITE : CONVERSATION.STATE.READ_ONLY
const newReadOnly = this.writingConversationSelected.value
this.isReadOnlyStateLoading = true
try {
await this.$store.dispatch('setReadOnlyState', {
Expand Down
17 changes: 15 additions & 2 deletions src/components/NewMessageForm/NewMessageForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ import EmojiPicker from '@nextcloud/vue/dist/Components/EmojiPicker'
import { EventBus } from '../../services/EventBus'
import { shareFile } from '../../services/filesSharingServices'
import { processFiles } from '../../utils/fileUpload'
import { CONVERSATION } from '../../constants'
import { CONVERSATION, PARTICIPANT } from '../../constants'
import createTemporaryMessage from '../../utils/temporaryMessage'
import EmoticonOutline from 'vue-material-design-icons/EmoticonOutline'
import Send from 'vue-material-design-icons/Send'
Expand Down Expand Up @@ -178,7 +178,20 @@ export default {
},
isReadOnly() {
return this.conversation.readOnly === CONVERSATION.STATE.READ_ONLY
return (this.conversation.readOnly === CONVERSATION.STATE.READ_ONLY)
|| (this.conversation.readOnly === CONVERSATION.STATE.WRITE_ONLY_MOD && !this.selfIsModerator)
},
currentParticipant() {
return this.$store.getters.conversation(this.token) || {
sessionId: '0',
participantType: this.$store.getters.getUserId() !== null ? PARTICIPANT.TYPE.USER : PARTICIPANT.TYPE.GUEST,
}
},
selfIsModerator() {
return this.currentParticipant.participantType === PARTICIPANT.TYPE.OWNER
|| this.currentParticipant.participantType === PARTICIPANT.TYPE.MODERATOR
},
disabled() {
Expand Down

0 comments on commit f35fd8e

Please sign in to comment.