Fixed tracker uploadOfflineRecording (#3048)
Co-authored-by: Jasper Baetsle <jasper.baetsle@orbid.be>
This commit is contained in:
parent
ef3ed8b690
commit
da9b926b25
1 changed files with 15 additions and 12 deletions
|
|
@ -918,7 +918,7 @@ export default class App {
|
|||
private postToWorker(messages: Array<Message>) {
|
||||
this.worker?.postMessage(messages)
|
||||
this.commitCallbacks.forEach((cb) => cb(messages))
|
||||
messages.length = 0
|
||||
//messages.length = 0
|
||||
}
|
||||
|
||||
private delay = 0
|
||||
|
|
@ -1638,18 +1638,21 @@ export default class App {
|
|||
|
||||
flushBuffer = async (buffer: Message[]) => {
|
||||
return new Promise((res) => {
|
||||
let ended = false
|
||||
const messagesBatch: Message[] = [buffer.shift() as unknown as Message]
|
||||
while (!ended) {
|
||||
const nextMsg = buffer[0]
|
||||
if (!nextMsg || nextMsg[0] === MType.Timestamp) {
|
||||
ended = true
|
||||
} else {
|
||||
messagesBatch.push(buffer.shift() as unknown as Message)
|
||||
if (buffer.length === 0) {
|
||||
res(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Since the first element is always a Timestamp, include it by default.
|
||||
let endIndex = 1;
|
||||
// Continue until you hit another Timestamp or run out of messages.
|
||||
while (endIndex < buffer.length && buffer[endIndex][0] !== MType.Timestamp) {
|
||||
endIndex++;
|
||||
}
|
||||
this.postToWorker(messagesBatch)
|
||||
res(null)
|
||||
|
||||
const messagesBatch = buffer.splice(0, endIndex);
|
||||
this.postToWorker(messagesBatch);
|
||||
res(null);
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue