@@ -89,11 +108,6 @@ export default {
data() {
return {
menuActions: [
- // NOTE: if menuActions is empty, the related slot is not shown
- {
- name: 'dummyItem',
- title: 'Just a dummy item',
- },
/*
{
name: 'inviteUser',
@@ -159,22 +173,7 @@ export default {
},
mounted() {
if (this.singleRoom) {
- this.$apollo
- .mutate({
- mutation: createRoom(),
- variables: {
- userId: this.roomId,
- },
- })
- .then(({ data: { CreateRoom } }) => {
- this.fetchRooms({ room: CreateRoom })
- })
- .catch((error) => {
- this.$toast.error(error)
- })
- .finally(() => {
- // this.loading = false
- })
+ this.newRoom(this.roomId)
} else {
this.fetchRooms()
}
@@ -182,9 +181,6 @@ export default {
// Subscriptions
const observer = this.$apollo.subscribe({
query: chatMessageAdded(),
- variables: {
- userId: this.currentUser.id,
- },
})
observer.subscribe({
@@ -197,10 +193,24 @@ export default {
computed: {
...mapGetters({
currentUser: 'auth/user',
+ getStoreRoomId: 'chat/roomID',
}),
computedChatStyle() {
return chatStyle.STYLE.light
},
+ computedRoomId() {
+ let roomId = null
+
+ if (!this.singleRoom) {
+ roomId = this.roomId
+
+ if (this.getStoreRoomId.roomId) {
+ roomId = this.getStoreRoomId.roomId
+ }
+ }
+
+ return roomId
+ },
textMessages() {
return {
ROOMS_EMPTY: this.$t('chat.roomsEmpty'),
@@ -221,10 +231,12 @@ export default {
methods: {
...mapMutations({
commitUnreadRoomCount: 'chat/UPDATE_ROOM_COUNT',
+ commitRoomIdFromSingleRoom: 'chat/UPDATE_ROOM_ID',
}),
- async fetchRooms({ room, options = {} } = {}) {
- this.roomsLoaded = options.refetch ? this.roomsLoaded : false
- const offset = (options.refetch ? 0 : this.roomPage) * this.roomPageSize
+
+ async fetchRooms({ room } = {}) {
+ this.roomsLoaded = false
+ const offset = this.roomPage * this.roomPageSize
try {
const {
data: { Room },
@@ -242,17 +254,7 @@ export default {
const rmsIds = []
;[...Room, ...this.rooms].forEach((r) => {
if (!rmsIds.find((v) => v === r.id)) {
- rms.push({
- ...r,
- index: r.lastMessage?.date,
- lastMessage: {
- ...r.lastMessage,
- content: r.lastMessage?.content.trim().substring(0, 30),
- },
- users: r.users.map((u) => {
- return { ...u, username: u.name, avatar: u.avatar?.url }
- }),
- })
+ rms.push(this.fixRoomObject(r))
rmsIds.push(r.id)
}
})
@@ -262,6 +264,13 @@ export default {
this.roomsLoaded = true
}
this.roomPage += 1
+
+ if (this.singleRoom && this.rooms.length > 0) {
+ this.commitRoomIdFromSingleRoom(this.rooms[0].roomId)
+ } else if (this.getStoreRoomId.roomId) {
+ // reset store room id
+ this.commitRoomIdFromSingleRoom(null)
+ }
} catch (error) {
this.rooms = []
this.$toast.error(error.message)
@@ -366,6 +375,10 @@ export default {
const changedRoom = { ...this.rooms[roomIndex] }
changedRoom.lastMessage = createdMessage
changedRoom.lastMessage.content = changedRoom.lastMessage.content.trim().substring(0, 30)
+ // move current room to top (not 100% working)
+ // const rooms = [...this.rooms]
+ // rooms.splice(roomIndex,1)
+ // this.rooms = [changedRoom, ...rooms]
this.rooms[roomIndex] = changedRoom
} catch (error) {
this.$toast.error(error.message)
@@ -380,6 +393,58 @@ export default {
if (!fullname) return
return fullname.match(/\b\w/g).join('').substring(0, 3).toUpperCase()
},
+
+ toggleUserSearch() {
+ this.$emit('toggle-user-search')
+ },
+
+ fixRoomObject(room) {
+ // This fixes the room object which arrives from the backend
+ const fixedRoom = {
+ ...room,
+ index: room.lastMessage ? room.lastMessage.date : room.createdAt,
+ lastMessage: room.lastMessage
+ ? {
+ ...room.lastMessage,
+ content: room.lastMessage?.content?.trim().substring(0, 30),
+ }
+ : null,
+ users: room.users.map((u) => {
+ return { ...u, username: u.name, avatar: u.avatar?.url }
+ }),
+ }
+ if (!fixedRoom.avatar) {
+ // as long as we cannot query avatar on CreateRoom
+ fixedRoom.avatar = fixedRoom.users.find((u) => u.id !== this.currentUser.id).avatar
+ }
+ return fixedRoom
+ },
+
+ newRoom(userId) {
+ this.$apollo
+ .mutate({
+ mutation: createRoom(),
+ variables: {
+ userId,
+ },
+ })
+ .then(({ data: { CreateRoom } }) => {
+ const roomIndex = this.rooms.findIndex((r) => r.id === CreateRoom.roomId)
+ const room = this.fixRoomObject(CreateRoom)
+
+ if (roomIndex === -1) {
+ this.rooms = [room, ...this.rooms]
+ }
+ this.fetchMessages({ room, options: { refetch: true } })
+ this.$emit('show-chat', CreateRoom.id)
+ })
+ .catch((error) => {
+ this.$toast.error(error.message)
+ })
+ .finally(() => {
+ // this.loading = false
+ })
+ },
},
}
@@ -408,4 +473,8 @@ body {
transform: translate(-50%, -50%);
}
}
+
+.ds-flex-item.single-chat-bubble {
+ margin-right: 1em;
+}
diff --git a/webapp/components/ChatNotificationMenu/ChatNotificationMenu.vue b/webapp/components/ChatNotificationMenu/ChatNotificationMenu.vue
index ec3f9fbc7..dd36b965a 100644
--- a/webapp/components/ChatNotificationMenu/ChatNotificationMenu.vue
+++ b/webapp/components/ChatNotificationMenu/ChatNotificationMenu.vue
@@ -44,11 +44,6 @@ export default {
},
subscribeToMore: {
document: roomCountUpdated(),
- variables() {
- return {
- userId: this.user.id,
- }
- },
updateQuery: (previousResult, { subscriptionData }) => {
return { UnreadRooms: subscriptionData.data.roomCountUpdated }
},
diff --git a/webapp/components/CommentForm/CommentForm.vue b/webapp/components/CommentForm/CommentForm.vue
index 5f6a2420d..6d9b59de6 100644
--- a/webapp/components/CommentForm/CommentForm.vue
+++ b/webapp/components/CommentForm/CommentForm.vue
@@ -8,7 +8,6 @@
:disabled="disabled && !update"
@click="handleCancel"
data-test="cancel-button"
- danger
>
{{ $t('actions.cancel') }}
diff --git a/webapp/components/ContentMenu/GroupContentMenu.vue b/webapp/components/ContentMenu/GroupContentMenu.vue
index 7a7737320..1ca1b5b33 100644
--- a/webapp/components/ContentMenu/GroupContentMenu.vue
+++ b/webapp/components/ContentMenu/GroupContentMenu.vue
@@ -58,14 +58,14 @@ export default {
routes.push({
label: this.$t('group.contentMenu.visitGroupPage'),
icon: 'home',
- name: 'group-id-slug',
+ path: `/groups/${this.group.id}`,
params: { id: this.group.id, slug: this.group.slug },
})
}
if (this.group.myRole === 'owner') {
routes.push({
label: this.$t('admin.settings.name'),
- path: `/group/edit/${this.group.id}`,
+ path: `/groups/edit/${this.group.id}`,
icon: 'edit',
})
}
diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue
index 0067dab72..b595357f9 100644
--- a/webapp/components/ContributionForm/ContributionForm.vue
+++ b/webapp/components/ContributionForm/ContributionForm.vue
@@ -169,12 +169,7 @@
-
+
{{ $t('actions.cancel') }}
diff --git a/webapp/components/Editor/Editor.vue b/webapp/components/Editor/Editor.vue
index cf0fd710b..8bc0a04d3 100644
--- a/webapp/components/Editor/Editor.vue
+++ b/webapp/components/Editor/Editor.vue
@@ -28,10 +28,10 @@ import { replace, build } from 'xregexp/xregexp-all.js'
import * as key from '../../constants/keycodes'
import { HASHTAG, MENTION } from '../../constants/editor'
-import defaultExtensions from './defaultExtensions.js'
-import EventHandler from './plugins/eventHandler.js'
-import Hashtag from './nodes/Hashtag.js'
-import Mention from './nodes/Mention.js'
+import defaultExtensions from './defaultExtensions'
+import EventHandler from './plugins/eventHandler'
+import Hashtag from './nodes/Hashtag'
+import Mention from './nodes/Mention'
import MenuBar from './MenuBar'
import ContextMenu from './ContextMenu'
import SuggestionList from './SuggestionList'
diff --git a/webapp/components/Group/AddGroupMember.vue b/webapp/components/Group/AddGroupMember.vue
index ff049ca4d..cc3e3b1e8 100644
--- a/webapp/components/Group/AddGroupMember.vue
+++ b/webapp/components/Group/AddGroupMember.vue
@@ -3,33 +3,7 @@
{{ $t('group.addUser') }}
-
-
-
-
-
-
-
+