Skip to content

Commit 6159317

Browse files
authored
Merge pull request #10603 from nextcloud/feat/10405/note-to-self
feat(conversation) - add Note to self conversation
2 parents 4df5ae8 + 7f84892 commit 6159317

File tree

11 files changed

+325
-83
lines changed

11 files changed

+325
-83
lines changed

docs/constants.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* `3` Public
99
* `4` Changelog
1010
* `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)
11+
* `6` Note to self
1112

1213
### Object types
1314

src/components/ConversationSettings/ConversationSettingsDialog.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636

3737
<template v-if="!isBreakoutRoom">
3838
<!-- Notifications settings and devices preview screen -->
39-
<NcAppSettingsSection id="notifications"
39+
<NcAppSettingsSection v-if="!isNoteToSelf"
40+
id="notifications"
4041
:title="t('spreed', 'Personal')">
4142
<NcCheckboxRadioSwitch :checked.sync="showMediaSettings"
4243
type="switch">
@@ -49,8 +50,8 @@
4950
<NcAppSettingsSection v-if="canFullModerate"
5051
id="conversation-settings"
5152
:title="t('spreed', 'Moderation')">
52-
<ListableSettings :token="token" />
53-
<LinkShareSettings ref="linkShareSettings" />
53+
<ListableSettings v-if="!isNoteToSelf" :token="token" />
54+
<LinkShareSettings v-if="!isNoteToSelf" ref="linkShareSettings" />
5455
<ExpirationSettings :token="token" can-full-moderate />
5556
</NcAppSettingsSection>
5657
<NcAppSettingsSection v-else
@@ -60,15 +61,15 @@
6061
</NcAppSettingsSection>
6162

6263
<!-- Meeting: lobby and sip -->
63-
<NcAppSettingsSection v-if="canFullModerate"
64+
<NcAppSettingsSection v-if="canFullModerate && !isNoteToSelf"
6465
id="meeting"
6566
:title="t('spreed', 'Meeting')">
6667
<LobbySettings :token="token" />
6768
<SipSettings v-if="canUserEnableSIP" />
6869
</NcAppSettingsSection>
6970

7071
<!-- Conversation permissions -->
71-
<NcAppSettingsSection v-if="canFullModerate"
72+
<NcAppSettingsSection v-if="canFullModerate && !isNoteToSelf"
7273
id="permissions"
7374
:title="t('spreed', 'Permissions')">
7475
<ConversationPermissionsSettings :token="token" />
@@ -99,7 +100,7 @@
99100
<NcAppSettingsSection v-if="canLeaveConversation || canDeleteConversation"
100101
id="dangerzone"
101102
:title="t('spreed', 'Danger zone')">
102-
<LockingSettings :token="token" />
103+
<LockingSettings v-if="canFullModerate && !isNoteToSelf" :token="token" />
103104
<DangerZone :conversation="conversation"
104105
:can-leave-conversation="canLeaveConversation"
105106
:can-delete-conversation="canDeleteConversation" />
@@ -173,6 +174,10 @@ export default {
173174
return this.conversation.canEnableSIP
174175
},
175176
177+
isNoteToSelf() {
178+
return this.conversation.type === CONVERSATION.TYPE.NOTE_TO_SELF
179+
},
180+
176181
token() {
177182
return this.$store.getters.getConversationSettingsToken()
178183
|| this.$store.getters.getToken()

src/components/LeftSidebar/LeftSidebar.vue

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@
9090
{{ t('spreed','Create a new conversation') }}
9191
</NcActionButton>
9292

93+
<NcActionButton v-if="!hasNoteToSelf"
94+
close-after-click
95+
@click="restoreNoteToSelfConversation">
96+
<template #icon>
97+
<Note :size="20" />
98+
</template>
99+
{{ t('spreed','New personal note') }}
100+
</NcActionButton>
101+
93102
<NcActionButton close-after-click
94103
@click="showModalListConversations">
95104
<template #icon>
@@ -239,6 +248,7 @@ import FilterIcon from 'vue-material-design-icons/Filter.vue'
239248
import FilterRemoveIcon from 'vue-material-design-icons/FilterRemove.vue'
240249
import List from 'vue-material-design-icons/FormatListBulleted.vue'
241250
import MessageBadge from 'vue-material-design-icons/MessageBadge.vue'
251+
import Note from 'vue-material-design-icons/NoteEditOutline.vue'
242252
import Plus from 'vue-material-design-icons/Plus.vue'
243253
244254
import { showError } from '@nextcloud/dialogs'
@@ -267,6 +277,7 @@ import { CONVERSATION } from '../../constants.js'
267277
import BrowserStorage from '../../services/BrowserStorage.js'
268278
import {
269279
createPrivateConversation,
280+
fetchNoteToSelfConversation,
270281
searchPossibleConversations,
271282
searchListedConversations,
272283
} from '../../services/conversationsService.js'
@@ -303,6 +314,7 @@ export default {
303314
ChatPlus,
304315
List,
305316
DotsVertical,
317+
Note,
306318
},
307319
308320
mixins: [
@@ -396,6 +408,10 @@ export default {
396408
return this.searchText !== ''
397409
},
398410
411+
hasNoteToSelf() {
412+
return this.conversationsList.find(conversation => conversation.type === CONVERSATION.TYPE.NOTE_TO_SELF)
413+
},
414+
399415
sourcesWithoutResults() {
400416
return !this.searchResultsUsers.length
401417
|| !this.searchResultsGroups.length
@@ -616,9 +632,7 @@ export default {
616632
}
617633
},
618634
619-
async createConversation(name) {
620-
const response = await createPrivateConversation(name)
621-
const conversation = response.data.ocs.data
635+
switchToConversation(conversation) {
622636
this.$store.dispatch('addConversation', conversation)
623637
this.abortSearch()
624638
this.$router.push({
@@ -627,6 +641,18 @@ export default {
627641
}).catch(err => console.debug(`Error while pushing the new conversation's route: ${err}`))
628642
},
629643
644+
async createConversation(name) {
645+
const response = await createPrivateConversation(name)
646+
const conversation = response.data.ocs.data
647+
this.switchToConversation(conversation)
648+
},
649+
650+
async restoreNoteToSelfConversation() {
651+
const response = await fetchNoteToSelfConversation()
652+
const conversation = response.data.ocs.data
653+
this.switchToConversation(conversation)
654+
},
655+
630656
hasOneToOneConversationWith(userId) {
631657
return !!this.conversationsList.find(conversation => conversation.type === CONVERSATION.TYPE.ONE_TO_ONE && conversation.name === userId)
632658
},

src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/Forwarder.vue

Lines changed: 5 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
</template>
6969

7070
<script>
71-
import cloneDeep from 'lodash/cloneDeep.js'
7271
7372
import Check from 'vue-material-design-icons/Check.vue'
7473
@@ -128,70 +127,22 @@ export default {
128127
return this.$store.getters?.conversation(this.selectedConversationToken).displayName
129128
},
130129
131-
/**
132-
* Object containing all the mentions in the message that will be forwarded
133-
*
134-
* @return {object} mentions.
135-
*/
136-
mentions() {
137-
const mentions = {}
138-
for (const key in this.messageObject.messageParameters) {
139-
if (key.startsWith('mention')) {
140-
mentions[key] = this.messageObject.messageParameters[key]
141-
}
142-
}
143-
return mentions
144-
},
145130
},
146131
147132
methods: {
148133
async setSelectedConversationToken(token) {
149134
this.selectedConversationToken = token
150-
const messageToBeForwarded = cloneDeep(this.messageObject)
151-
// Overwrite the selected conversation token
152-
messageToBeForwarded.token = token
153-
154-
if (messageToBeForwarded.parent) {
155-
delete messageToBeForwarded.parent
156-
}
157-
158-
if (messageToBeForwarded.message === '{object}' && messageToBeForwarded.messageParameters.object) {
159-
const richObject = messageToBeForwarded.messageParameters.object
160-
try {
161-
const response = await this.$store.dispatch('forwardRichObject', {
162-
token,
163-
richObject: {
164-
objectId: richObject.id,
165-
objectType: richObject.type,
166-
metaData: JSON.stringify(richObject),
167-
referenceId: '',
168-
},
169-
})
170-
this.showForwardedConfirmation = true
171-
this.forwardedMessageID = response.data.ocs.data.id
172-
} catch (error) {
173-
console.error('Error while forwarding message', error)
174-
showError(t('spreed', 'Error while forwarding message'))
175-
}
176-
return
177-
}
178-
179-
// If there are mentions in the message to be forwarded, replace them in the message
180-
// text.
181-
if (this.mentions !== {}) {
182-
for (const mention in this.mentions) {
183-
messageToBeForwarded.message = messageToBeForwarded.message.replace(`{${mention}}`, '@' + this.mentions[mention].name)
184-
}
185-
}
186135
try {
187-
const response = await this.$store.dispatch('forwardMessage', { messageToBeForwarded })
188-
this.showForwardedConfirmation = true
136+
const response = await this.$store.dispatch('forwardMessage', {
137+
targetToken: this.selectedConversationToken,
138+
messageToBeForwarded: this.messageObject,
139+
})
189140
this.forwardedMessageID = response.data.ocs.data.id
141+
this.showForwardedConfirmation = true
190142
} catch (error) {
191143
console.error('Error while forwarding message', error)
192144
showError(t('spreed', 'Error while forwarding message'))
193145
}
194-
195146
},
196147
197148
openConversation() {

src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@
111111
</template>
112112
{{ t('spreed', 'Go to file') }}
113113
</NcActionLink>
114+
<NcActionButton v-if="canForwardMessage && !isInNoteToSelf"
115+
close-after-click
116+
@click="forwardToNote">
117+
<template #icon>
118+
<Note :size="16" />
119+
</template>
120+
{{ t('spreed', 'Note to self') }}
121+
</NcActionButton>
114122
<NcActionButton v-if="canForwardMessage"
115123
close-after-click
116124
@click.stop="openForwarder">
@@ -256,6 +264,7 @@ import DeleteIcon from 'vue-material-design-icons/Delete.vue'
256264
import EmoticonOutline from 'vue-material-design-icons/EmoticonOutline.vue'
257265
import EyeOffOutline from 'vue-material-design-icons/EyeOffOutline.vue'
258266
import File from 'vue-material-design-icons/File.vue'
267+
import Note from 'vue-material-design-icons/NoteEditOutline.vue'
259268
import OpenInNewIcon from 'vue-material-design-icons/OpenInNew.vue'
260269
import Plus from 'vue-material-design-icons/Plus.vue'
261270
import Reply from 'vue-material-design-icons/Reply.vue'
@@ -311,6 +320,7 @@ export default {
311320
EmoticonOutline,
312321
EyeOffOutline,
313322
File,
323+
Note,
314324
OpenInNewIcon,
315325
Plus,
316326
Reply,
@@ -536,6 +546,10 @@ export default {
536546
&& this.messageParameters?.object?.type === 'talk-poll'
537547
},
538548
549+
isInNoteToSelf() {
550+
return this.conversation.type === CONVERSATION.TYPE.NOTE_TO_SELF
551+
},
552+
539553
canForwardMessage() {
540554
return !this.isCurrentGuest
541555
&& !this.isFileShare
@@ -702,6 +716,16 @@ export default {
702716
this.$emit('update:isReactionsMenuOpen', true)
703717
},
704718
719+
async forwardToNote() {
720+
try {
721+
await this.$store.dispatch('forwardMessage', { messageToBeForwarded: this.messageObject })
722+
showSuccess(t('spreed', 'Message forwarded to "Note to self"'))
723+
} catch (error) {
724+
console.error('Error while forwarding message to "Note to self"', error)
725+
showError(t('spreed', 'Error while forwarding message to "Note to self"'))
726+
}
727+
},
728+
705729
openForwarder() {
706730
this.$emit('update:isForwarderOpen', true)
707731
},

src/components/RightSidebar/RightSidebar.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</template>
4242
<ChatView :is-visible="opened" />
4343
</NcAppSidebarTab>
44-
<NcAppSidebarTab v-if="(getUserId || isModeratorOrUser) && !isOneToOne"
44+
<NcAppSidebarTab v-if="showParticipantsTab"
4545
id="participants"
4646
ref="participantsTab"
4747
:order="2"
@@ -266,6 +266,14 @@ export default {
266266
&& (this.breakoutRoomsConfigured || this.conversation.breakoutRoomMode === CONVERSATION.BREAKOUT_ROOM_MODE.FREE || this.conversation.objectType === 'room')
267267
},
268268
269+
showParticipantsTab() {
270+
return (this.getUserId || this.isModeratorOrUser) && !this.isOneToOne && !this.isNoteToSelf
271+
},
272+
273+
isNoteToSelf() {
274+
return this.conversation.type === CONVERSATION.TYPE.NOTE_TO_SELF
275+
},
276+
269277
breakoutRoomsText() {
270278
return t('spreed', 'Breakout rooms')
271279
},
@@ -277,7 +285,7 @@ export default {
277285
this.conversationName = this.conversation.displayName
278286
}
279287
280-
if (newConversation.token === oldConversation.token || this.isOneToOne) {
288+
if (newConversation.token === oldConversation.token || !this.showParticipantsTab) {
281289
return
282290
}
283291
@@ -294,10 +302,10 @@ export default {
294302
}
295303
},
296304
297-
isOneToOne: {
305+
showParticipantsTab: {
298306
immediate: true,
299307
handler(value) {
300-
if (value) {
308+
if (!value) {
301309
this.activeTab = 'shared-items'
302310
}
303311
},

src/components/TopBar/CallButton.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ export default {
254254
255255
showStartCallButton() {
256256
return this.callEnabled
257+
&& this.conversation.type !== CONVERSATION.TYPE.NOTE_TO_SELF
257258
&& this.conversation.readOnly === CONVERSATION.STATE.READ_WRITE
258259
&& !this.isInCall
259260
},

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export const CONVERSATION = {
7272
PUBLIC: 3,
7373
CHANGELOG: 4,
7474
ONE_TO_ONE_FORMER: 5,
75+
NOTE_TO_SELF: 6,
7576
},
7677

7778
BREAKOUT_ROOM_MODE: {

src/services/conversationsService.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ const searchListedConversations = async function({ searchText }, options) {
6161
}))
6262
}
6363

64+
/**
65+
* Generate note-to-self conversation
66+
*
67+
*/
68+
const fetchNoteToSelfConversation = async function() {
69+
return axios.get(generateOcsUrl('apps/spreed/api/v4/room/note-to-self'))
70+
}
71+
6472
/**
6573
* Fetch possible conversations
6674
*
@@ -438,6 +446,7 @@ const deleteConversationAvatar = async function(token) {
438446
export {
439447
fetchConversations,
440448
fetchConversation,
449+
fetchNoteToSelfConversation,
441450
searchListedConversations,
442451
searchPossibleConversations,
443452
createOneToOneConversation,

0 commit comments

Comments
 (0)