mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
remove setTimeout
This commit is contained in:
parent
c21026e28a
commit
ac6bbf1840
@ -146,7 +146,7 @@ export default {
|
|||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchMessages({ room, options = {} }) {
|
async fetchMessages({ room, options = {} }) {
|
||||||
if (this.lastRoom !== room.id) {
|
if (this.lastRoom !== room.id) {
|
||||||
this.messages = []
|
this.messages = []
|
||||||
this.messagePage = 0
|
this.messagePage = 0
|
||||||
@ -154,35 +154,33 @@ export default {
|
|||||||
}
|
}
|
||||||
this.messagesLoaded = options.refetch ? this.messagesLoaded : false
|
this.messagesLoaded = options.refetch ? this.messagesLoaded : false
|
||||||
const offset = (options.refetch ? 0 : this.messagePage) * this.messagePageSize
|
const offset = (options.refetch ? 0 : this.messagePage) * this.messagePageSize
|
||||||
setTimeout(async () => {
|
try {
|
||||||
try {
|
const {
|
||||||
const {
|
data: { Message },
|
||||||
data: { Message },
|
} = await this.$apollo.query({
|
||||||
} = await this.$apollo.query({
|
query: messageQuery(),
|
||||||
query: messageQuery(),
|
variables: {
|
||||||
variables: {
|
roomId: room.id,
|
||||||
roomId: room.id,
|
first: this.messagePageSize,
|
||||||
first: this.messagePageSize,
|
offset,
|
||||||
offset,
|
},
|
||||||
},
|
fetchPolicy: 'no-cache',
|
||||||
fetchPolicy: 'no-cache',
|
})
|
||||||
})
|
|
||||||
|
|
||||||
const msgs = []
|
const msgs = []
|
||||||
;[...this.messages, ...Message].forEach((m) => {
|
;[...this.messages, ...Message].forEach((m) => {
|
||||||
msgs[m.indexId] = m
|
msgs[m.indexId] = m
|
||||||
})
|
})
|
||||||
this.messages = msgs.filter(Boolean)
|
this.messages = msgs.filter(Boolean)
|
||||||
|
|
||||||
if (Message.length < this.messagePageSize) {
|
if (Message.length < this.messagePageSize) {
|
||||||
this.messagesLoaded = true
|
this.messagesLoaded = true
|
||||||
}
|
|
||||||
this.messagePage += 1
|
|
||||||
} catch (error) {
|
|
||||||
this.messages = []
|
|
||||||
this.$toast.error(error.message)
|
|
||||||
}
|
}
|
||||||
})
|
this.messagePage += 1
|
||||||
|
} catch (error) {
|
||||||
|
this.messages = []
|
||||||
|
this.$toast.error(error.message)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
refetchMessage(roomId) {
|
refetchMessage(roomId) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user