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
1 change: 1 addition & 0 deletions docs/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* `3` Public
* `4` Changelog
* `5` Former "One to one" (When a user is deleted from the server or removed from all their conversations, `1` "One to one" rooms are converted to this type)
* `6` Note to self

### Object types

Expand Down
17 changes: 11 additions & 6 deletions src/components/ConversationSettings/ConversationSettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@

<template v-if="!isBreakoutRoom">
<!-- Notifications settings and devices preview screen -->
<NcAppSettingsSection id="notifications"
<NcAppSettingsSection v-if="!isNoteToSelf"
id="notifications"
:title="t('spreed', 'Personal')">
<NcCheckboxRadioSwitch :checked.sync="showMediaSettings"
type="switch">
Expand All @@ -49,8 +50,8 @@
<NcAppSettingsSection v-if="canFullModerate"
id="conversation-settings"
:title="t('spreed', 'Moderation')">
<ListableSettings :token="token" />
<LinkShareSettings ref="linkShareSettings" />
<ListableSettings v-if="!isNoteToSelf" :token="token" />
<LinkShareSettings v-if="!isNoteToSelf" ref="linkShareSettings" />
<ExpirationSettings :token="token" can-full-moderate />
</NcAppSettingsSection>
<NcAppSettingsSection v-else
Expand All @@ -60,15 +61,15 @@
</NcAppSettingsSection>

<!-- Meeting: lobby and sip -->
<NcAppSettingsSection v-if="canFullModerate"
<NcAppSettingsSection v-if="canFullModerate && !isNoteToSelf"
id="meeting"
:title="t('spreed', 'Meeting')">
<LobbySettings :token="token" />
<SipSettings v-if="canUserEnableSIP" />
</NcAppSettingsSection>

<!-- Conversation permissions -->
<NcAppSettingsSection v-if="canFullModerate"
<NcAppSettingsSection v-if="canFullModerate && !isNoteToSelf"
id="permissions"
:title="t('spreed', 'Permissions')">
<ConversationPermissionsSettings :token="token" />
Expand Down Expand Up @@ -99,7 +100,7 @@
<NcAppSettingsSection v-if="canLeaveConversation || canDeleteConversation"
id="dangerzone"
:title="t('spreed', 'Danger zone')">
<LockingSettings :token="token" />
<LockingSettings v-if="canFullModerate && !isNoteToSelf" :token="token" />
<DangerZone :conversation="conversation"
:can-leave-conversation="canLeaveConversation"
:can-delete-conversation="canDeleteConversation" />
Expand Down Expand Up @@ -173,6 +174,10 @@ export default {
return this.conversation.canEnableSIP
},

isNoteToSelf() {
return this.conversation.type === CONVERSATION.TYPE.NOTE_TO_SELF
},

token() {
return this.$store.getters.getConversationSettingsToken()
|| this.$store.getters.getToken()
Expand Down
32 changes: 29 additions & 3 deletions src/components/LeftSidebar/LeftSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@
{{ t('spreed','Create a new conversation') }}
</NcActionButton>

<NcActionButton v-if="!hasNoteToSelf"
close-after-click
@click="restoreNoteToSelfConversation">
<template #icon>
<Note :size="20" />
</template>
{{ t('spreed','New personal note') }}
</NcActionButton>

<NcActionButton close-after-click
@click="showModalListConversations">
<template #icon>
Expand Down Expand Up @@ -239,6 +248,7 @@ import FilterIcon from 'vue-material-design-icons/Filter.vue'
import FilterRemoveIcon from 'vue-material-design-icons/FilterRemove.vue'
import List from 'vue-material-design-icons/FormatListBulleted.vue'
import MessageBadge from 'vue-material-design-icons/MessageBadge.vue'
import Note from 'vue-material-design-icons/NoteEditOutline.vue'
import Plus from 'vue-material-design-icons/Plus.vue'

import { showError } from '@nextcloud/dialogs'
Expand Down Expand Up @@ -267,6 +277,7 @@ import { CONVERSATION } from '../../constants.js'
import BrowserStorage from '../../services/BrowserStorage.js'
import {
createPrivateConversation,
fetchNoteToSelfConversation,
searchPossibleConversations,
searchListedConversations,
} from '../../services/conversationsService.js'
Expand Down Expand Up @@ -303,6 +314,7 @@ export default {
ChatPlus,
List,
DotsVertical,
Note,
},

mixins: [
Expand Down Expand Up @@ -396,6 +408,10 @@ export default {
return this.searchText !== ''
},

hasNoteToSelf() {
return this.conversationsList.find(conversation => conversation.type === CONVERSATION.TYPE.NOTE_TO_SELF)
},

sourcesWithoutResults() {
return !this.searchResultsUsers.length
|| !this.searchResultsGroups.length
Expand Down Expand Up @@ -616,9 +632,7 @@ export default {
}
},

async createConversation(name) {
const response = await createPrivateConversation(name)
const conversation = response.data.ocs.data
switchToConversation(conversation) {
this.$store.dispatch('addConversation', conversation)
this.abortSearch()
this.$router.push({
Expand All @@ -627,6 +641,18 @@ export default {
}).catch(err => console.debug(`Error while pushing the new conversation's route: ${err}`))
},

async createConversation(name) {
const response = await createPrivateConversation(name)
const conversation = response.data.ocs.data
this.switchToConversation(conversation)
},

async restoreNoteToSelfConversation() {
const response = await fetchNoteToSelfConversation()
const conversation = response.data.ocs.data
this.switchToConversation(conversation)
},

hasOneToOneConversationWith(userId) {
return !!this.conversationsList.find(conversation => conversation.type === CONVERSATION.TYPE.ONE_TO_ONE && conversation.name === userId)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
</template>

<script>
import cloneDeep from 'lodash/cloneDeep.js'

import Check from 'vue-material-design-icons/Check.vue'

Expand Down Expand Up @@ -128,70 +127,22 @@ export default {
return this.$store.getters?.conversation(this.selectedConversationToken).displayName
},

/**
* Object containing all the mentions in the message that will be forwarded
*
* @return {object} mentions.
*/
mentions() {
const mentions = {}
for (const key in this.messageObject.messageParameters) {
if (key.startsWith('mention')) {
mentions[key] = this.messageObject.messageParameters[key]
}
}
return mentions
},
},

methods: {
async setSelectedConversationToken(token) {
this.selectedConversationToken = token
const messageToBeForwarded = cloneDeep(this.messageObject)
// Overwrite the selected conversation token
messageToBeForwarded.token = token

if (messageToBeForwarded.parent) {
delete messageToBeForwarded.parent
}

if (messageToBeForwarded.message === '{object}' && messageToBeForwarded.messageParameters.object) {
const richObject = messageToBeForwarded.messageParameters.object
try {
const response = await this.$store.dispatch('forwardRichObject', {
token,
richObject: {
objectId: richObject.id,
objectType: richObject.type,
metaData: JSON.stringify(richObject),
referenceId: '',
},
})
this.showForwardedConfirmation = true
this.forwardedMessageID = response.data.ocs.data.id
} catch (error) {
console.error('Error while forwarding message', error)
showError(t('spreed', 'Error while forwarding message'))
}
return
}

// If there are mentions in the message to be forwarded, replace them in the message
// text.
if (this.mentions !== {}) {
for (const mention in this.mentions) {
messageToBeForwarded.message = messageToBeForwarded.message.replace(`{${mention}}`, '@' + this.mentions[mention].name)
}
}
try {
const response = await this.$store.dispatch('forwardMessage', { messageToBeForwarded })
this.showForwardedConfirmation = true
const response = await this.$store.dispatch('forwardMessage', {
targetToken: this.selectedConversationToken,
messageToBeForwarded: this.messageObject,
})
this.forwardedMessageID = response.data.ocs.data.id
this.showForwardedConfirmation = true
} catch (error) {
console.error('Error while forwarding message', error)
showError(t('spreed', 'Error while forwarding message'))
}

},

openConversation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@
</template>
{{ t('spreed', 'Go to file') }}
</NcActionLink>
<NcActionButton v-if="canForwardMessage && !isInNoteToSelf"
close-after-click
@click="forwardToNote">
<template #icon>
<Note :size="16" />
</template>
{{ t('spreed', 'Note to self') }}
</NcActionButton>
<NcActionButton v-if="canForwardMessage"
close-after-click
@click.stop="openForwarder">
Expand Down Expand Up @@ -256,6 +264,7 @@ import DeleteIcon from 'vue-material-design-icons/Delete.vue'
import EmoticonOutline from 'vue-material-design-icons/EmoticonOutline.vue'
import EyeOffOutline from 'vue-material-design-icons/EyeOffOutline.vue'
import File from 'vue-material-design-icons/File.vue'
import Note from 'vue-material-design-icons/NoteEditOutline.vue'
import OpenInNewIcon from 'vue-material-design-icons/OpenInNew.vue'
import Plus from 'vue-material-design-icons/Plus.vue'
import Reply from 'vue-material-design-icons/Reply.vue'
Expand Down Expand Up @@ -311,6 +320,7 @@ export default {
EmoticonOutline,
EyeOffOutline,
File,
Note,
OpenInNewIcon,
Plus,
Reply,
Expand Down Expand Up @@ -536,6 +546,10 @@ export default {
&& this.messageParameters?.object?.type === 'talk-poll'
},

isInNoteToSelf() {
return this.conversation.type === CONVERSATION.TYPE.NOTE_TO_SELF
},

canForwardMessage() {
return !this.isCurrentGuest
&& !this.isFileShare
Expand Down Expand Up @@ -702,6 +716,16 @@ export default {
this.$emit('update:isReactionsMenuOpen', true)
},

async forwardToNote() {
try {
await this.$store.dispatch('forwardMessage', { messageToBeForwarded: this.messageObject })
showSuccess(t('spreed', 'Message forwarded to "Note to self"'))
} catch (error) {
console.error('Error while forwarding message to "Note to self"', error)
showError(t('spreed', 'Error while forwarding message to "Note to self"'))
}
},

openForwarder() {
this.$emit('update:isForwarderOpen', true)
},
Expand Down
16 changes: 12 additions & 4 deletions src/components/RightSidebar/RightSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</template>
<ChatView :is-visible="opened" />
</NcAppSidebarTab>
<NcAppSidebarTab v-if="(getUserId || isModeratorOrUser) && !isOneToOne"
<NcAppSidebarTab v-if="showParticipantsTab"
id="participants"
ref="participantsTab"
:order="2"
Expand Down Expand Up @@ -266,6 +266,14 @@ export default {
&& (this.breakoutRoomsConfigured || this.conversation.breakoutRoomMode === CONVERSATION.BREAKOUT_ROOM_MODE.FREE || this.conversation.objectType === 'room')
},

showParticipantsTab() {
return (this.getUserId || this.isModeratorOrUser) && !this.isOneToOne && !this.isNoteToSelf
},

isNoteToSelf() {
return this.conversation.type === CONVERSATION.TYPE.NOTE_TO_SELF
},

breakoutRoomsText() {
return t('spreed', 'Breakout rooms')
},
Expand All @@ -277,7 +285,7 @@ export default {
this.conversationName = this.conversation.displayName
}

if (newConversation.token === oldConversation.token || this.isOneToOne) {
if (newConversation.token === oldConversation.token || !this.showParticipantsTab) {
return
}

Expand All @@ -294,10 +302,10 @@ export default {
}
},

isOneToOne: {
showParticipantsTab: {
immediate: true,
handler(value) {
if (value) {
if (!value) {
this.activeTab = 'shared-items'
}
},
Expand Down
1 change: 1 addition & 0 deletions src/components/TopBar/CallButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export default {

showStartCallButton() {
return this.callEnabled
&& this.conversation.type !== CONVERSATION.TYPE.NOTE_TO_SELF
&& this.conversation.readOnly === CONVERSATION.STATE.READ_WRITE
&& !this.isInCall
},
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const CONVERSATION = {
PUBLIC: 3,
CHANGELOG: 4,
ONE_TO_ONE_FORMER: 5,
NOTE_TO_SELF: 6,
},

BREAKOUT_ROOM_MODE: {
Expand Down
9 changes: 9 additions & 0 deletions src/services/conversationsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ const searchListedConversations = async function({ searchText }, options) {
}))
}

/**
* Generate note-to-self conversation
*
*/
const fetchNoteToSelfConversation = async function() {
return axios.get(generateOcsUrl('apps/spreed/api/v4/room/note-to-self'))
}

/**
* Fetch possible conversations
*
Expand Down Expand Up @@ -438,6 +446,7 @@ const deleteConversationAvatar = async function(token) {
export {
fetchConversations,
fetchConversation,
fetchNoteToSelfConversation,
searchListedConversations,
searchPossibleConversations,
createOneToOneConversation,
Expand Down
Loading