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
|
const data = (await res.json()) as MessagesPayload
|
||||||
if (!stopped) {
|
if (!stopped) {
|
||||||
callback(data)
|
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
|
lastSince = newest
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -224,7 +227,10 @@ export async function subscribeMachineMessages(
|
||||||
(value) => {
|
(value) => {
|
||||||
stopPoll()
|
stopPoll()
|
||||||
callback(value)
|
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
|
lastSince = newest
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue