From 65af20d7cc62e3d54ae7857b2b9b711fd5de0b98 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 1 Oct 2020 11:16:08 +0200 Subject: [PATCH] Fix history 'loadMore' with trimmed history --- www/common/sframe-common-history.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/www/common/sframe-common-history.js b/www/common/sframe-common-history.js index 1ccec88be..506abeffb 100644 --- a/www/common/sframe-common-history.js +++ b/www/common/sframe-common-history.js @@ -214,6 +214,16 @@ define([ var messages = (data.messages || []).map(function (obj) { return obj; }); + + // We're supposed to receive 2 checkpoints. If the result is only ONE message + // and this message is a checkpoint, it means it's the last message of the history + // (and this is a trimmed history) + if (messages.length === 1) { + var parsed = JSON.parse(messages[0].msg); + if (parsed[0] === 4) { + isComplete = true; + } + } if (config.debug) { console.log(data.messages); } Array.prototype.unshift.apply(allMessages, messages); // Destructive concat fillChainPad(realtime, allMessages);