Commit 71bcbbc2 by Kim Peace

Fixed chat room loading indicator timing

parent 1de8bd84
......@@ -78,6 +78,9 @@ document.addEventListener("readystatechange", () => {
case "interactive":
break;
case "complete":
if (typeof initialLoading != "undefined" && initialLoading) {
break;
}
Common.dismissLoadingIndicator();
break;
}
......
......@@ -388,9 +388,9 @@ ReverseDelegate.leaveRoom = function () {
};
// for android call
ReverseDelegate.displayExistRoom = function (roomId) {
ReverseDelegate.displayExistRoom = function (roomID) {
if (confirm("error_already_exist_same_user")) {
NativeBridgeDelegate.joinRoom(roomId);
NativeBridgeDelegate.joinRoom(roomID);
}
return;
};
......@@ -2,6 +2,7 @@ var beforeHeight = window.innerHeight;
var beforeWidth = window.innerWidth;
var beforeScroll;
var roomName = "";
var initialLoading = true;
var ChatRoom = {};
window.onscroll = function () {
......@@ -13,6 +14,7 @@ window.onscroll = function () {
messageCount = $(".chat_message").length;
// TODO: peacekim :: check this condition
if ($(this).scrollTop() === 0 && messageCount >= PagingSize.MESSAGE) {
setTimeout(function () {
if (!$("#chatLoader").is(":visible")) {
// display loading indicator in chat message
let loader = $(
......@@ -20,7 +22,7 @@ window.onscroll = function () {
);
$("#messages").append(loader);
// get lastest message id and update message from server via native
const messageID = $($(".chat_message").get(0)).data("messageid");
const messageID = $($(".chat_message").last()).data("messageid");
NativeBridgeDelegate.updatePreMessage(messageID);
let messages = NativeBridgeDataSource.getMessagesByMessageID(messageID);
// prepend message
......@@ -30,6 +32,7 @@ window.onscroll = function () {
var afterHeight = $(".room_container").height();
window.scroll(0, afterHeight - beforeHeight);
}
}, 0);
}
};
......@@ -176,7 +179,11 @@ ChatRoom.scrollToBottom = function (animated = true) {
{
scrollTop: scrollHeight,
},
animated ? 100 : 0
animated ? 100 : 0,
function () {
initialLoading = false;
Common.dismissLoadingIndicator();
}
);
};
......
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