desktop/chat: tipar reduce e manter fallback
This commit is contained in:
parent
e08dc21003
commit
3aee1a6694
1 changed files with 8 additions and 2 deletions
|
|
@ -201,7 +201,10 @@ export async function subscribeMachineMessages(
|
|||
const data = (await res.json()) as MessagesPayload
|
||||
if (!stopped) {
|
||||
callback(data)
|
||||
const newest = data.messages.reduce((max, msg) => Math.max(max, msg.createdAt), lastSince)
|
||||
const newest = (data.messages as ChatMessage[]).reduce(
|
||||
(max: number, msg: ChatMessage) => Math.max(max, msg.createdAt),
|
||||
lastSince
|
||||
)
|
||||
lastSince = newest
|
||||
}
|
||||
} catch (err) {
|
||||
|
|
@ -224,7 +227,10 @@ export async function subscribeMachineMessages(
|
|||
(value) => {
|
||||
stopPoll()
|
||||
callback(value)
|
||||
const newest = value.messages.reduce((max, msg) => Math.max(max, msg.createdAt), lastSince)
|
||||
const newest = (value.messages as ChatMessage[]).reduce(
|
||||
(max: number, msg: ChatMessage) => Math.max(max, msg.createdAt),
|
||||
lastSince
|
||||
)
|
||||
lastSince = newest
|
||||
},
|
||||
(err) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue