Commit 1de8bd84 by Kim Peace

Fixed message display order to colomn reversed

parent 24a59d1f
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
<!-- チャット内容 --> <!-- チャット内容 -->
<div class="room_container"> <div class="room_container">
<div class="room_contents scroll"> <div class="room_contents scroll">
<div id="messages"></div> <div id="messages" class="message_container"></div>
</div> </div>
</div> </div>
</main> </main>
......
...@@ -478,23 +478,30 @@ input[name="tab_item"] { ...@@ -478,23 +478,30 @@ input[name="tab_item"] {
margin: 0 auto; margin: 0 auto;
} }
.message_container {
display: flex;
flex-direction: column-reverse;
}
.room_container { .room_container {
padding: 0; padding: 0;
background: #f3f3f3; background: #f3f3f3;
overflow: hidden; overflow: hidden;
margin: 20px auto; margin: 20px auto;
margin-bottom: 140px; margin-bottom: 140px;
flex-direction: column-reverse;
} }
/* 会話部分 */ /* 会話部分 */
.room_contents { .room_contents {
padding: 10px; padding: 10px;
overflow: hidden; overflow: hidden;
line-height: 150%; line-height: 150%;
} }
.scroll { .scroll {
overflow-y: scroll; overflow-y: scroll;
} }
/* 相手の会話 */ /* 相手の会話 */
.room_left { .room_left {
width: fit-content; width: fit-content;
......
...@@ -102,7 +102,7 @@ CHAT_SOCKET.addCollaborationMessage = function ( ...@@ -102,7 +102,7 @@ CHAT_SOCKET.addCollaborationMessage = function (
createdAt createdAt
); );
$("#messages").append(html); $("#messages").prepend(html);
}; };
CHAT_SOCKET.getMeetingID = function (collaborationType, messageInfo) { CHAT_SOCKET.getMeetingID = function (collaborationType, messageInfo) {
...@@ -177,7 +177,7 @@ CHAT_SOCKET.addTextMessage = function (messageText, message, socketID) { ...@@ -177,7 +177,7 @@ CHAT_SOCKET.addTextMessage = function (messageText, message, socketID) {
message.userId, message.userId,
message.createdAt message.createdAt
); );
$("#messages").append(html); $("#messages").prepend(html);
}; };
CHAT_SOCKET.renderTextMessage = function ( CHAT_SOCKET.renderTextMessage = function (
......
...@@ -13,7 +13,7 @@ ChatRoom.appendSearchMessages = function (messages, unwrappedWorkVal = "") { ...@@ -13,7 +13,7 @@ ChatRoom.appendSearchMessages = function (messages, unwrappedWorkVal = "") {
let html = ChatRoom.renderMessageForSearchMessage(message); let html = ChatRoom.renderMessageForSearchMessage(message);
workVal = html + workVal; workVal = html + workVal;
}); });
$(".overlay_src_msg").prepend(workVal); $(".overlay_src_msg").append(workVal);
}; };
ChatRoom.renderMessageForSearchMessage = function (message) { ChatRoom.renderMessageForSearchMessage = function (message) {
...@@ -147,9 +147,8 @@ ChatRoom.appendAttendedUsers = function (roomID) { ...@@ -147,9 +147,8 @@ ChatRoom.appendAttendedUsers = function (roomID) {
ChatRoom.prependMessage = function (messages) { ChatRoom.prependMessage = function (messages) {
const now = new Date(); const now = new Date();
// メッセージ文字列の生成
let workVal = "";
const messageElement = $("#messages");
let checkBeforeDate = ""; let checkBeforeDate = "";
let beforeDate = ""; let beforeDate = "";
messages.forEach(function (message) { messages.forEach(function (message) {
...@@ -176,19 +175,16 @@ ChatRoom.prependMessage = function (messages) { ...@@ -176,19 +175,16 @@ ChatRoom.prependMessage = function (messages) {
&& !isToday && !isToday
) { ) {
const html = ChatRoom.renderDateLabelMessage(beforeDate); const html = ChatRoom.renderDateLabelMessage(beforeDate);
workVal = html + workVal; messageElement.append(html);
} }
checkBeforeDate = messageCreatedTime; checkBeforeDate = messageCreatedTime;
beforeDate = message.insertDate; beforeDate = message.insertDate;
const html = ChatRoom.renderMessage(message, isToday, isOtherYear); const html = ChatRoom.renderMessage(message, isToday, isOtherYear);
workVal = html + workVal; messageElement.append(html);
}); });
// メッセージの画面描画
$("#messages").prepend(workVal);
// messageが存在する場合、最上段にそのメッセージの日付を表示 // messageが存在する場合、最上段にそのメッセージの日付を表示
ChatRoom.appendInitialDateMessage(messages); ChatRoom.appendInitialDateMessage(messages);
}; };
...@@ -200,7 +196,7 @@ ChatRoom.appendInitialDateMessage = function (messages) { ...@@ -200,7 +196,7 @@ ChatRoom.appendInitialDateMessage = function (messages) {
messages[messages.length - 1].insertDate, messages[messages.length - 1].insertDate,
true true
); );
$("#messages").prepend(html); $("#messages").append(html);
} }
}; };
......
...@@ -11,16 +11,21 @@ window.onscroll = function () { ...@@ -11,16 +11,21 @@ window.onscroll = function () {
beforeScroll = window.scrollY; beforeScroll = window.scrollY;
const beforeHeight = $(".room_container").height(); const beforeHeight = $(".room_container").height();
messageCount = $(".chat_message").length; messageCount = $(".chat_message").length;
// TODO: peacekim :: check this condition
if ($(this).scrollTop() === 0 && messageCount >= PagingSize.MESSAGE) { if ($(this).scrollTop() === 0 && messageCount >= PagingSize.MESSAGE) {
if (!$("#chatLoader").is(":visible")) { if (!$("#chatLoader").is(":visible")) {
// display loading indicator in chat message
let loader = $( let loader = $(
'<div id="chatLoader" class="text-center"><div class="spinner-grow spinner-grow-sm" role="status" /></div>' '<div id="chatLoader" class="text-center"><div class="spinner-grow spinner-grow-sm" role="status" /></div>'
); );
$("#messages").prepend(loader); $("#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").get(0)).data("messageid");
NativeBridgeDelegate.updatePreMessage(messageID); NativeBridgeDelegate.updatePreMessage(messageID);
let messages = NativeBridgeDataSource.getMessagesByMessageID(messageID); let messages = NativeBridgeDataSource.getMessagesByMessageID(messageID);
// prepend message
ChatRoom.prependMessage(messages); ChatRoom.prependMessage(messages);
// hide loading indicator
loader.remove(); loader.remove();
var afterHeight = $(".room_container").height(); var afterHeight = $(".room_container").height();
window.scroll(0, afterHeight - beforeHeight); window.scroll(0, afterHeight - beforeHeight);
...@@ -123,21 +128,6 @@ ChatRoom.bindUserListDisplayToggle = function () { ...@@ -123,21 +128,6 @@ ChatRoom.bindUserListDisplayToggle = function () {
}); });
}; };
//上にスクロールすると新しいメッセージを呼ぶ処理。
$("#messages").scroll(function () {
if ($(this).scrollTop() === 0) {
if (!$("#chatLoader").is(":visible")) {
// 現在、メッセージの個数以前をメッセージを読み込む
// ローディングアイコンを追加する
let loader = $(
'<div id="chatLoader" class="text-center"><div class="spinner-grow spinner-grow-sm" role="status" /></div>'
);
$("#messages").prepend(loader);
loader.remove();
}
}
});
// 画像の読み込みが全て終わったタイミングでコールバック実行 // 画像の読み込みが全て終わったタイミングでコールバック実行
// FIXME 追加読み込みの場合は差分の画像のみ監視すべきだが、現状新規入室時にしか対応出来ていない。 // FIXME 追加読み込みの場合は差分の画像のみ監視すべきだが、現状新規入室時にしか対応出来ていない。
ChatRoom.waitForLoadingVideo = function (div, callback) { ChatRoom.waitForLoadingVideo = function (div, callback) {
......
...@@ -15,6 +15,7 @@ FermiWebSocketBridge.shareFileHost = function (collaborationType) { ...@@ -15,6 +15,7 @@ FermiWebSocketBridge.shareFileHost = function (collaborationType) {
}; };
FermiWebSocketBridge.hostChangeResponse = function () { FermiWebSocketBridge.hostChangeResponse = function () {
// TODO: peacekim:: check loginID is for fw or not
fw.sendToMsg("others", "HOST_CHANGE_RESPONSE", { fw.sendToMsg("others", "HOST_CHANGE_RESPONSE", {
isAndroid: deviceInfo.isAndroid(), isAndroid: deviceInfo.isAndroid(),
isAble: deviceInfo.androidVersion >= ANDROID_SDK_VERSION.O, isAble: deviceInfo.androidVersion >= ANDROID_SDK_VERSION.O,
......
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