@@ -89,11 +110,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 +175,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 +183,6 @@ export default {
// Subscriptions
const observer = this.$apollo.subscribe({
query: chatMessageAdded(),
- variables: {
- userId: this.currentUser.id,
- },
})
observer.subscribe({
@@ -197,10 +195,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 +233,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 +256,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 +266,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 +377,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 +395,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 +475,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..0a5eba0cd 100644
--- a/webapp/components/ContributionForm/ContributionForm.vue
+++ b/webapp/components/ContributionForm/ContributionForm.vue
@@ -1,190 +1,190 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('contribution.inappropriatePicture') }}
+
+
+
+
+
-
+ {{ formData.title.length }}/{{ formSchema.title.max }}
+
+
+
-
-
-
-
-
- {{ $t('contribution.inappropriatePicture') }}
-
-
-
-
-
-
- {{ formData.title.length }}/{{ formSchema.title.max }}
-
-
-
-
- {{ contentLength }}
-
-
+
+ {{ contentLength }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ {{ formData.eventVenue.length }}/{{ formSchema.eventVenue.max }}
+
+
+
+
+
+
+
+
+ {{ formData.eventLocationName.length }}/{{ formSchema.eventLocationName.max }}
+
+
+
+
+
-
+
-
-
-
-
-
-
-
- {{ formData.eventVenue.length }}/{{ formSchema.eventVenue.max }}
-
-
-
-
-
-
-
-
- {{ formData.eventLocationName.length }}/{{ formSchema.eventLocationName.max }}
-
-
-
-
-
-
-
-
- {{ $t('post.viewEvent.eventIsOnline') }}
+ {{ $t('post.viewEvent.eventIsOnline') }}
+
-
-
-
-
- {{ formData.categoryIds.length }} / 3
-
-
-
-
-
-
+
+
+
+ {{ formData.categoryIds.length }} / 3
+
+
+
+
+
+
+
+
diff --git a/webapp/store/chat.js b/webapp/store/chat.js
index ed6b5256c..1e0b496ac 100644
--- a/webapp/store/chat.js
+++ b/webapp/store/chat.js
@@ -14,6 +14,9 @@ export const mutations = {
UPDATE_ROOM_COUNT(state, count) {
state.unreadRoomCount = count
},
+ UPDATE_ROOM_ID(state, roomid) {
+ state.roomId = roomid || null
+ },
}
export const getters = {