Commit 71bcbbc2 by Kim Peace

Fixed chat room loading indicator timing

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