Commit c9e99c56 by Kim Peace

Merge branch 'feature/add_user_in_collaboration' into debug/console_logs

# Conflicts:
#	public_new/js/sockets/chat-websocket-message.js
#	public_new/js/views/collaboration/collaboration-add-user.js
#	public_new/js/views/collaboration/share-event-listener.js
parents e6d5fa69 3e3da3c4
......@@ -179,7 +179,7 @@ Common.startCollaboration = function (collaborationType) {
return;
}
const sendData = DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL;
CHAT_SOCKET.emitCreateMessage(sendData, 0);
CHAT_SOCKET.emitCreateMessage(SOCKET_KEY.CREATE_MESSAGE, sendData);
NativeBridgeDelegate.finishAllCollaboration();
}
NativeBridgeDelegate.startCollaboration(collaborationType);
......
......@@ -131,6 +131,7 @@ const SOCKET_KEY = {
DISCONNECT: "disconnect",
CONNECT_ERROR: "connect_error",
NEW_MESSAGE: "newMessage",
NEW_COMMUNICATION: "newCommunication",
NEW_NOTIFICATION: "newNotification",
REFRESH_GROUPLIST: "refreshGroupList",
REFRESH_USERLIST_INGROUP: "refreshUserListInGroup",
......@@ -138,6 +139,10 @@ const SOCKET_KEY = {
RETRY_JOIN_PROCESS: "retryJoinProcess",
JOIN: "join",
CREATE_MESSAGE: "createMessage",
CREATE_TEXT: "createText",
CREATE_IMAGE: "createImage",
CREATE_VIDEO: "createVideo",
COMMUNICATION: "communication",
GET_GROUP_LIST: "getGroupList",
LEAVE_ROOM: "leaveRoom",
};
......
......@@ -10,49 +10,62 @@ CHAT_SOCKET.bindOnNewMessage = function () {
", roomName: " +
roomName
);
const systemMessageTemplate = getTemplate(TemplateURL.SYSTEM_MESSAGE);
const unwrappedMessageInfo = CHAT_SOCKET.decodeMessage(message.text);
if (
unwrappedMessageInfo ==
DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL
) {
CHAT_SOCKET.cleanUpCollaborationMessage();
return;
}
if (unwrappedMessageInfo.includes(messageSeperator)) {
const messageInfo = unwrappedMessageInfo.split(messageSeperator);
const messageText = messageInfo[0];
const messageType = messageInfo[1];
if (
messageType == MessageType.COMMUNICATIONSTART ||
messageType == MessageType.COMMUNICATIONEND
) {
CHAT_SOCKET.addCollaborationMessage(
messageInfo,
message.userId,
roomName,
message.insertDate,
message.createdAt
);
} else {
CHAT_SOCKET.addTextMessage(messageText, message, socket.id);
}
}
if (typeof ChatRoom !== "undefined") {
// 画像、動画の描画を待ってからスクロール
setTimeout(function () {
ChatRoom.scrollToBottom();
}, 300);
} else {
Common.dismissLoadingIndicator();
}
CHAT_SOCKET.handleMessage(message, roomName, SOCKET_KEY.NEW_MESSAGE)
});
socket.on(SOCKET_KEY.NEW_COMMUNICATION, function (message, roomID, roomName) {
console.log(
"peacekim:: on SOCKET_KEY.NEW_COMMUNICATION message: " +
message +
", roomID: " +
roomID +
", roomName: " +
roomName
);
CHAT_SOCKET.handleMessage(message, roomName, SOCKET_KEY.NEW_COMMUNICATION)
});
};
CHAT_SOCKET.handleMessage = function (message, roomName, socketKey) {
const systemMessageTemplate = getTemplate(TemplateURL.SYSTEM_MESSAGE);
const unwrappedMessageInfo = CHAT_SOCKET.decodeMessage(message.text);
if (
unwrappedMessageInfo ==
DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL
) {
CHAT_SOCKET.cleanUpCollaborationMessage();
return;
}
const messageInfo = unwrappedMessageInfo;
const messageType = socketKey;
const messageText = unwrappedMessageInfo;
if (
messageType == SOCKET_KEY.NEW_COMMUNICATION
) {
CHAT_SOCKET.addCollaborationMessage(
messageInfo,
message.userId,
roomName,
message.insertDate,
message.createdAt
);
} else {
CHAT_SOCKET.addTextMessage(messageText, message, socket.id);
}
if (typeof ChatRoom !== "undefined") {
// 画像、動画の描画を待ってからスクロール
setTimeout(function () {
ChatRoom.scrollToBottom();
}, 300);
} else {
Common.dismissLoadingIndicator();
}
}
CHAT_SOCKET.decodeMessage = function (text) {
try {
return decodeURIComponent(text);
......@@ -232,7 +245,7 @@ CHAT_SOCKET.cleanUpCollaborationMessage = function () {
.attr("disabled", "disabled");
$(collaborationMessage)
.find(".collaboration_join_message")
.text(getLocalizedString("flex-directionmessage_ended"));
.text(getLocalizedString("message_ended"));
});
};
......
......@@ -203,14 +203,60 @@ var bindOnRefreshUserListInGroup = function () {
);
};
CHAT_SOCKET.emitCreateMessage = function (sendData, offset) {
socket.emit(SOCKET_KEY.CREATE_MESSAGE, { text: sendData }, offset);
var nextFibonacci = function (num) {
let nextNum = num * (1 + Math.sqrt(5)) / 2.0;
return Math.round(nextNum);
}
CHAT_SOCKET.emitCreateMessage = function (socketKey, sendData) {
if (socket.connected == false) {
CHAT_SOCKET.reconnectCreateMessage(socketKey, sendData);
} else {
socket.emit(socketKey, { text: sendData });
}
};
CHAT_SOCKET.emitCreateText = function (sendData) {
CHAT_SOCKET.emitCreateMessage(SOCKET_KEY.CREATE_TEXT, sendData);
};
CHAT_SOCKET.emitCreateImage = function (sendData) {
CHAT_SOCKET.emitCreateMessage(SOCKET_KEY.CREATE_IMAGE, sendData);
};
CHAT_SOCKET.emitCreateVideo = function (sendData) {
CHAT_SOCKET.emitCreateMessage(SOCKET_KEY.CREATE_VIDEO, sendData);
};
CHAT_SOCKET.emitCreateCommunicationStart = function (sendData, collaborationType, meetingID) {
if (socket.connected == false) {
CHAT_SOCKET.reconnectCreateMessage(SOCKET_KEY.COMMUNICATION, sendData, collaborationType, meetingID);
} else {
socket.emit(SOCKET_KEY.COMMUNICATION, { text: sendData }, collaborationType, meetingID);
}
};
CHAT_SOCKET.reconnectCreateMessage = function (socketKey, sendData, timeout = 100, collaborationType = null, meetingID = null) {
if (socket.connected == false) {
console.log("socket disconnected, reconnect... " + timeout)
CHAT_SOCKET.initialJoin();
setTimeout(function() {
CHAT_SOCKET.reconnectCreateMessage(socketKey, sendData, nextFibonacci(timeout));
}, timeout);
} else {
console.log("reconnected")
if (collaborationType == null) {
socket.emit(socketKey, { text: sendData });
} else {
socket.emit(socketKey, { text: sendData }, collaborationType, meetingID);
}
}
}
CHAT_SOCKET.emitCollaborationFinishMessage = function () {
if (socket != null && socket.connected) {
const sendData = DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL;
CHAT_SOCKET.emitCreateMessage(sendData, 0);
CHAT_SOCKET.emitCreateMessage(SOCKET_KEY.CREATE_MESSAGE, sendData);
}
};
......
......@@ -169,8 +169,8 @@ ChatMediaHandler.videoEncodeEnd = function (encodedUri) {
} catch (e) {
encodedText = text;
}
const sendData = encodedText + messageSeperator + MessageType.VIDEO;
CHAT_SOCKET.emitCreateMessage(sendData, 1);
const sendData = encodedText;
CHAT_SOCKET.emitCreateVideo(sendData);
$(".overlay").removeClass("active undismissable");
$(".loader").removeClass("active");
......@@ -320,8 +320,8 @@ ChatMediaHandler.uploadImage = function (formData) {
} catch (e) {
encodedText = text;
}
const sendData = encodedText + messageSeperator + MessageType.IMAGE;
CHAT_SOCKET.emitCreateMessage(sendData, 1);
const sendData = encodedText;
CHAT_SOCKET.emitCreateImage(sendData);
} else {
// 動画の処理
if (res.thumbnailPath && res.thumbnailPath.length > 0) {
......@@ -371,8 +371,8 @@ ChatMediaHandler.uploadImage = function (formData) {
} catch (e) {
encodedText = text;
}
const sendData = encodedText + messageSeperator + MessageType.VIDEO;
CHAT_SOCKET.emitCreateMessage(sendData, 1);
const sendData = encodedText;
CHAT_SOCKET.emitCreateVideo(sendData);
}
$(".overlay").removeClass("active undismissable");
......
......@@ -23,7 +23,7 @@ ArchiveUI.refreshSearchScreen = function (keyword) {
);
let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").append(obj);
$(".overlay_src_msg").prepend(obj);
});
});
};
......@@ -340,7 +340,7 @@ ArchiveUI.refreshArchiveScreen = function () {
typeImage: typeImage,
});
const obj = $(jQuery.parseHTML(html)).on("click", function () {});
$("#archiveList").append(obj);
$("#archiveList").prepend(obj);
});
// loadingIndicatorを非表示
......
......@@ -71,8 +71,8 @@ ChatRoom.sendMessage = function (e) {
messageTextBox.val("");
if (message.length > 0) {
const sendData = message + messageSeperator + MessageType.TEXT;
CHAT_SOCKET.emitCreateMessage(sendData, 0);
const sendData = message;
CHAT_SOCKET.emitCreateText(sendData);
}
$(".message_input_form").focus();
};
......
......@@ -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 () {
console.log("peacekim:: chat-room DOMContentLoaded");
// 検索イベントバインディング
......
......@@ -159,7 +159,7 @@ CollaborationUI.refreshAllGroupForAddUserInCollaboration = function (groupID) {
CollaborationUI.appendChildGroups(result.childGroupList);
//該当グループの所属ユーザを表示。
CollaborationUI.appendUsers();
CollaborationUI.appendUsers(result.groupUserList);
};
CollaborationUI.bindOnClickParentGroup = function (parentGroupID) {
......@@ -183,7 +183,7 @@ CollaborationUI.displayRootGroupAndParentGroupIfNeeded = function (
groupID
) {
console.log("peacekim:: CollaborationUI.displayRootGroupAndParentGroupIfNeeded");
if (typeof rootGroupID !== "undefined" && paramGroupID == 0) {
if (typeof rootGroupID !== "undefined" && rootGroupID == 0) {
groupID = rootGroupID;
}
......
......@@ -74,14 +74,16 @@ CollaborationUI.bindChangeHostButton = function () {
CollaborationUI.bindCloseButton = function () {
$(".close_btn").click(function () {
$("#overlay_add_user_list").addClass("none");
$("#add_user_list").addClass("none");
$(".modal-backdrop").addClass("none");
CollaborationUI.bindDisableScroll();
});
};
CollaborationUI.bindInviteButton = function () {
$(".inv_btn").click(function () {
$("#overlay_add_user_list").addClass("none");
$("#add_user_list").addClass("none");
});
};
......
......@@ -256,18 +256,16 @@ CollaborationFeature.didReceiveCreateRoomResponseMessage = function () {
console.log(
"peacekim:: CollaborationFeature.didReceiveCreateRoomResponseMessage"
);
let coviewInviteMessage =
"" +
messageSeperator +
MessageType.COMMUNICATIONSTART +
messageSeperator +
CHAT_UTIL.getCollaborationTypeNumber(globalUserInfo.collaborationType);
let coviewInviteMessage = "";
let collaborationType = CHAT_UTIL.getCollaborationTypeNumber(globalUserInfo.collaborationType);
let meetingID = null
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.DOCUMENT) {
coviewInviteMessage += messageSeperator + globalUserInfo.meetingID;
meetingID = globalUserInfo.meetingID;
}
CHAT_SOCKET.emitCreateMessage(coviewInviteMessage, 0);
CHAT_SOCKET.emitCreateCommunicationStart(coviewInviteMessage, collaborationType, meetingID);
};
CollaborationFeature.didReceivedJoinRoomInfoResponseMessage = function () {
......
<!-- コンテンツ -->
<div class="modal fade add_user_modal" id="addUserInCollaboration" tabindex="-1" role="dialog" aria-labelledby="addUserInCollaboration" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal_collaboration_user" role="document">
<div class="modal-content" style="position: fixed;width: 100%;height:100%;top: 0px;left:0;">
<div class="modal fade add_user_modal" id="addUserInCollaboration" tabindex="-1" role="dialog"
aria-labelledby="addUserInCollaboration" aria-hidden="true">
<div class="modal-dialog-centered modal_collaboration_user" role="document">
<div class="modal-content">
<form id="addUserFormInCollaboration" action="chat_add_user_confirm.html" method="post">
<!-- ユーザー検索 -->
<!-- タブ -->
......@@ -9,7 +10,8 @@
<div class="row h-100 align-items-center">
<div class="col-4 pr-0">
<div class="nav-item">
<a href="#" class="close_btn" class="close" data-dismiss="modal" aria-label="Close">閉じる</a>
<a href="#" class="close_btn" class="close" data-dismiss="modal"
aria-label="Close">閉じる</a>
</div>
</div>
<div class="col-4 p-0">
......@@ -20,19 +22,23 @@
</div><!-- .row -->
</nav><!-- nav -->
<div class="content tabs">
<input id="tabMyGroupOnAddUserInCollaboration" type="radio" name="tab_item" checked onclick="CollaborationUI.refreshMyGroupForAddUserInCollaboration();">
<input id="tabMyGroupOnAddUserInCollaboration" type="radio" name="tab_item" checked
onclick="CollaborationUI.refreshMyGroupForAddUserInCollaboration();">
<label class="tab_item m-0" for="tabMyGroupOnAddUserInCollaboration">マイグループ</label>
<input id="tabAllGroupOnAddUserInCollaboration" type="radio" name="tab_item" onclick="CollaborationUI.refreshAllGroupForAddUserInCollaboration('0');">
<input id="tabAllGroupOnAddUserInCollaboration" type="radio" name="tab_item"
onclick="CollaborationUI.refreshAllGroupForAddUserInCollaboration('0');">
<label class="tab_item m-0" for="tabAllGroupOnAddUserInCollaboration">全グループ</label>
<div class="tab_content" id="tab1_content" style="height: 100vh; overflow:scroll;">
<div class="tab_content" id="tab1_content">
<div class="chat_list">
<!-- お気に入りグループ -->
<div class="category" onclick="CollaborationUI.toggleCategory(this);"><div class="category_name"><span>お気に入り</span></div></div>
<div class="category" onclick="CollaborationUI.toggleCategory(this);">
<div class="category_name"><span>お気に入り</span></div>
</div>
<div id="favoriteListForAddUserInCollaboration"></div>
<div id="myGroupListForAddUserInCollaboration"></div>
</div>
</div>
<div class="tab_content" id="tab2_content" style="height: 100vh; overflow:scroll;">
<div class="tab_content" id="tab2_content">
<div class="breadcrumb" id="groupPathAreaForAddUserInCollaboration"></div>
<div class="chat_list">
<!-- 全グループ -->
......@@ -80,7 +86,7 @@
</div>
</div>
<!-- ルーム解説ボタン -->
<div class="add_user_confirm_btn content" id="addUserConfirmBtnInCollaboration" style="position: fixed;">
<div class="add_user_confirm_btn content" id="addUserConfirmBtnInCollaboration">
<button type="button" name="button" id="buttonAddUser" style="bottom: 0; width: 100%;">
確認<br>
<span class="select_member_num"></span><span class="select_member">名 選択中</span></button>
......@@ -88,4 +94,4 @@
</form>
</div>
</div>
</div>
</div>
\ No newline at end of file
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