Commit 4e33aa3f by Kim Peace

Merge branch 'fix/load_100_more_messages' into 'develop'

Fix/load 100 more messages

See merge request !215
parents c2726ba9 0cc53fa4
......@@ -186,7 +186,7 @@ CHAT_SOCKET.cleanUpCollaborationMessage = function () {
.attr("disabled", "disabled");
$(collaborationMessage)
.find(".collaboration_join_message")
.text(getLocalizedString("flex-directionmessage_ended"));
.text(getLocalizedString("message_ended"));
});
};
......
......@@ -12,30 +12,39 @@ window.onscroll = function () {
beforeScroll = window.scrollY;
const beforeHeight = $(".room_container").height();
messageCount = $(".chat_message").length;
// TODO: peacekim :: check this condition
if ($(this).scrollTop() === 0 && messageCount >= PagingSize.MESSAGE) {
setTimeout(function () {
setTimeout(() => {
if (!$("#chatLoader").is(":visible")) {
// display loading indicator in chat message
let loader = $(
'<div id="chatLoader" class="text-center"><div class="spinner-grow spinner-grow-sm" role="status" /></div>'
);
$("#messages").append(loader);
// get lastest message id and update message from server via native
const messageID = $($(".chat_message").last()).data("messageid");
NativeBridgeDelegate.updatePreMessage(messageID);
let messages = NativeBridgeDataSource.getMessagesByMessageID(messageID);
}
ChatRoom.loadNewMessage().then((messages) => {
// prepend message
ChatRoom.prependMessage(messages);
// hide loading indicator
loader.remove();
var afterHeight = $(".room_container").height();
if (typeof loader !== "undefined") {
loader.remove();
}
const afterHeight = $(".room_container").height();
window.scroll(0, afterHeight - beforeHeight);
}
});
}, 0);
}
};
ChatRoom.loadNewMessage = async function () {
return new Promise(function (done) {
// get lastest message id and update message from server via native
const messageID = $($(".chat_message").last()).data("messageid");
NativeBridgeDelegate.updatePreMessage(messageID);
let messages = NativeBridgeDataSource.getMessagesByMessageID(messageID);
done(messages);
});
};
document.addEventListener("DOMContentLoaded", function () {
// 検索イベントバインディング
ChatRoom.bindSearchUI();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment