mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
lint fixes
This commit is contained in:
parent
01fb28da3c
commit
70a1c52165
@ -401,20 +401,22 @@ export default {
|
|||||||
this.$emit('toggle-user-search')
|
this.$emit('toggle-user-search')
|
||||||
},
|
},
|
||||||
|
|
||||||
fixRoomObject(room){
|
fixRoomObject(room) {
|
||||||
// This fixes the room object which arrives from the backend
|
// This fixes the room object which arrives from the backend
|
||||||
const fixedRoom = {
|
const fixedRoom = {
|
||||||
...room,
|
...room,
|
||||||
index: room.lastMessage?.date,
|
index: room.lastMessage?.date,
|
||||||
lastMessage: room.lastMessage ? {
|
lastMessage: room.lastMessage
|
||||||
...room.lastMessage,
|
? {
|
||||||
content: room.lastMessage?.content?.trim().substring(0, 30),
|
...room.lastMessage,
|
||||||
}: null,
|
content: room.lastMessage?.content?.trim().substring(0, 30),
|
||||||
|
}
|
||||||
|
: null,
|
||||||
users: room.users.map((u) => {
|
users: room.users.map((u) => {
|
||||||
return { ...u, username: u.name, avatar: u.avatar?.url }
|
return { ...u, username: u.name, avatar: u.avatar?.url }
|
||||||
})
|
}),
|
||||||
}
|
}
|
||||||
if(!fixedRoom.avatar){
|
if (!fixedRoom.avatar) {
|
||||||
// as long as we cannot query avatar on CreateRoom
|
// as long as we cannot query avatar on CreateRoom
|
||||||
fixedRoom.avatar = fixedRoom.users.find((u) => u.id !== this.currentUser.id).avatar
|
fixedRoom.avatar = fixedRoom.users.find((u) => u.id !== this.currentUser.id).avatar
|
||||||
}
|
}
|
||||||
@ -433,10 +435,10 @@ export default {
|
|||||||
const roomIndex = this.rooms.findIndex((r) => r.id === CreateRoom.roomId)
|
const roomIndex = this.rooms.findIndex((r) => r.id === CreateRoom.roomId)
|
||||||
const room = this.fixRoomObject(CreateRoom)
|
const room = this.fixRoomObject(CreateRoom)
|
||||||
|
|
||||||
if(roomIndex === -1){
|
if (roomIndex === -1) {
|
||||||
this.rooms = [room, ...this.rooms]
|
this.rooms = [room, ...this.rooms]
|
||||||
}
|
}
|
||||||
this.fetchMessages({room, options: { refetch: true }})
|
this.fetchMessages({ room, options: { refetch: true } })
|
||||||
this.$emit('show-chat', CreateRoom.id)
|
this.$emit('show-chat', CreateRoom.id)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ export const createRoom = () => gql`
|
|||||||
|
|
||||||
export const roomQuery = () => gql`
|
export const roomQuery = () => gql`
|
||||||
query Room($first: Int, $offset: Int, $id: ID) {
|
query Room($first: Int, $offset: Int, $id: ID) {
|
||||||
Room(first: $first, offset: $offset, id: $id, orderBy: [lastMessageAt_desc createdAt_desc] ) {
|
Room(first: $first, offset: $offset, id: $id, orderBy: [lastMessageAt_desc, createdAt_desc]) {
|
||||||
id
|
id
|
||||||
roomId
|
roomId
|
||||||
roomName
|
roomName
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user