Commit a3648cec by Takatoshi Miura

iosローカルdb連動

parent c5b0f5af
......@@ -16,7 +16,7 @@
<script>
window.addEventListener('DOMContentLoaded', function() {
CHAT_DB.callGetArchiveList();
CHAT_DB.getArchiveList();
});
</script>
</head>
......
......@@ -20,7 +20,7 @@
var urlSearch = location.search.substring(1).split('&');
var kv = urlSearch[0].split('=');
urlPrm[kv[0]]=kv[1];
CHAT_DB.callGetArchiveDetail(urlPrm.archiveId);
CHAT_DB.getArchiveDetail(urlPrm.archiveId);
});
</script>
</head>
......
......@@ -19,11 +19,10 @@ function callNativeApp(iosKey, jsonData) {
return result;
}
//ロカールDBからルーム一覧情報を取得
CHAT_DB.getRoomList = function(roomType, keyWord) {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getRoomList", {"roomType": roomType, "keyWord": keyWord}));
} else if (CHAT_UTIL.isAndroid()) {
return JSON.parse(android.getRoomList(roomType, keyWord));
}
......@@ -31,7 +30,7 @@ CHAT_DB.getRoomList = function(roomType, keyWord) {
CHAT_DB.callGetRoomList = function(roomType) {
if (CHAT_UTIL.isIOS()) {
return callNativeApp(getRoomList, {"roomType":roomType});
return JSON.parse(callNativeApp("getRoomList", {"roomType": roomType}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getRoomList(roomType));
......@@ -41,7 +40,7 @@ CHAT_DB.callGetRoomList = function(roomType) {
//ロカールDBからログインしたユーザのデータを取得する。
CHAT_DB.getMyInfo = function() {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getMyInfo", {}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getMyInfo());
......@@ -50,7 +49,7 @@ CHAT_DB.getMyInfo = function() {
CHAT_DB.getMessages = function(roomId) {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getMessages", {"roomId": roomId}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getMessageList(roomId));
......@@ -59,7 +58,7 @@ CHAT_DB.getMessages = function(roomId) {
CHAT_DB.getFavoriteUsers = function() {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getFavoriteUsers", {}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getFavoriteUsers());
......@@ -68,7 +67,7 @@ CHAT_DB.getFavoriteUsers = function() {
CHAT_DB.getFavoriteGroups = function() {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getFavoriteGroups", {}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getFavoriteGroups());
......@@ -77,7 +76,7 @@ CHAT_DB.getFavoriteGroups = function() {
CHAT_DB.getMyGroupUsers = function() {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getMyGroupUsers", {}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getMyGroupUsers());
......@@ -86,7 +85,7 @@ CHAT_DB.getMyGroupUsers = function() {
CHAT_DB.getGroupInfo = function(groupId) {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getGroupInfo", {"groupId": groupId}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getGroupInfo(groupId));
......@@ -95,7 +94,7 @@ CHAT_DB.getGroupInfo = function(groupId) {
CHAT_DB.getNameCardData = function(shopMemberId) {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getNameCardData", {"shopMemberId": shopMemberId}));
} else if (CHAT_UTIL.isAndroid()) {
return JSON.parse(android.getNameCardData(shopMemberId));
}
......@@ -103,7 +102,7 @@ CHAT_DB.getNameCardData = function(shopMemberId) {
CHAT_DB.getMyGroupShopMemberByName = function(shopMemberName) {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getMyGroupShopMemberByName", {"shopMemberName": shopMemberName}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getMyGroupShopMemberByName(shopMemberName));
......@@ -112,7 +111,7 @@ CHAT_DB.getMyGroupShopMemberByName = function(shopMemberName) {
CHAT_DB.getAllGroupShopMemberByName = function(shopMemberName) {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getAllGroupShopMemberByName", {"shopMemberName": shopMemberName}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getAllGroupShopMemberByName(shopMemberName));
......@@ -121,7 +120,7 @@ CHAT_DB.getAllGroupShopMemberByName = function(shopMemberName) {
CHAT_DB.getGroupByName = function(groupName) {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getGroupByName", {"groupName": groupName}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getGroupByName(groupName));
......@@ -130,7 +129,7 @@ CHAT_DB.getGroupByName = function(groupName) {
CHAT_DB.getUsersInRoom = function(roomId) {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getUsersInRoom", {"roomId": roomId}));
} else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn
return JSON.parse(android.getUsersInRoom(roomId));
......@@ -140,28 +139,15 @@ CHAT_DB.getUsersInRoom = function(roomId) {
// アーカイブ一覧
CHAT_DB.getArchiveList = function() {
if (CHAT_UTIL.isIOS()) {
iosArchiveList = "";
webkit.messageHandlers.getArchiveList.postMessage();
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while (iosKey == "objc-processing") {};
if (iosKey == "archiveList") {
iosKey = "objc-processing";
return JSON.parse(iosArchiveList);
}
return JSON.parse(callNativeApp("getArchiveList", {}));
} else if (CHAT_UTIL.isAndroid()) {
// TODO
}
};
CHAT_DB.getIosArchiveList = function(archiveList) {
iosArchiveList = archiveList;
iosKey = "archiveList";
};
CHAT_DB.updateArchiveList = function() {
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.updateArchiveList.postMessage();
webkit.messageHandlers.updateArchiveList.postMessage({});
} else if (CHAT_UTIL.isAndroid()) {
// TODO
}
......@@ -170,47 +156,21 @@ CHAT_DB.updateArchiveList = function() {
// アーカイブ一覧検索
CHAT_DB.getArchiveByName = function(archiveName) {
if (CHAT_UTIL.isIOS()) {
iosSearchArchiveList = "";
webkit.messageHandlers.getArchiveByName.postMessage({archiveName});
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while (iosKey == "objc-processing") {};
if (iosKey == "searchArchiveList") {
iosKey = "objc-processing";
return JSON.parse(iosSearchArchiveList);
}
return JSON.parse(callNativeApp("getArchiveByName", {"archiveName": archiveName}));
} else if (CHAT_UTIL.isAndroid()) {
// TODO
}
};
CHAT_DB.getIosSearchArchiveList = function(archiveList) {
iosSearchArchiveList = archiveList;
iosKey = "searchArchiveList";
};
// アーカイブ詳細
CHAT_DB.getArchiveDetail = function(archiveId) {
if (CHAT_UTIL.isIOS()) {
iosArchiveDetail = "";
webkit.messageHandlers.getArchiveDetail.postMessage({archiveId});
// JavascriptからObjective-cのメソッドを指定してコールバックを受ける方法がないため、
// 値が入るまで待たせている。
while (iosKey == "objc-processing") {};
if (iosKey == "archiveDetail") {
iosKey = "objc-processing";
return JSON.parse(iosArchiveDetail);
}
return JSON.parse(callNativeApp("getArchiveDetail", {"archiveId": archiveId}));
} else if (CHAT_UTIL.isAndroid()) {
// TODO
}
};
CHAT_DB.getIosArchiveDetail = function(archiveDetail) {
iosArchiveDetail = archiveDetail;
iosKey = "archiveDetail";
};
CHAT_DB.updateArchiveDetail = function(archiveId) {
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.updateArchiveDetail.postMessage({archiveId});
......
......@@ -126,6 +126,7 @@ $('#room-search').on('input', function(event) {
} else {
if (IS_ONLINE == 'true') {
android.updateRoomList();
webkit.messageHandlers.updateRoomList.postMessage({});
CHAT_UI.refreshRoomList(chatRoomType.DM);
CHAT_UI.dismissLoadingIndicator();
}
......@@ -418,6 +419,7 @@ $('a[data-toggle="pill"]').on('show.bs.tab', function(e) {
if (IS_ONLINE == 'true') {
socket.emit('leaveRoom', function() {
android.updateRoomList();
webkit.messageHandlers.updateRoomList.postMessage({});
});
}
CHAT_UI.refreshRoomList(chatRoomType.DM);
......@@ -944,6 +946,11 @@ CHAT_UI.refreshContactScreen = function() {
android.updateMyInfo();
android.updateGroupUser();
android.updateFavorite();
webkit.messageHandlers.updateGroupInfo.postMessage({'0'});
webkit.messageHandlers.updateMyInfo.postMessage({});
webkit.messageHandlers.updateGroupUser.postMessage({});
webkit.messageHandlers.updateFavorite.postMessage({});
}
var myInfo = CHAT_DB.getMyInfo();
......@@ -1017,6 +1024,7 @@ CHAT_UI.refreshRoomList = function(roomType) {
if (IS_ONLINE == 'true') {
android.updateRoomList();
webkit.messageHandlers.updateRoomList.postMessage({});
}
var rooms = CHAT_DB.getRoomList(roomType, null);
CHAT.globalIsInvite = false;
......@@ -1104,12 +1112,14 @@ CHAT_UI.refreshRoomList = function(roomType) {
CHAT_UI.joinRoom = function(roomId,roomName) {
//native側に入場対象のroomId,roomNameを保存。(ルーム詳細画面初期化の時に使用。)
android.joinRoom(roomId,roomName);
webkit.messageHandlers.roomInfosaveMessageHandlerId.postMessage({"roomId": roomId, "roomName": roomName});
};
CHAT_UI.loadMessages = function(roomId, roomName) {
if (IS_ONLINE == 'true') {
CHAT_SOCKET.connectSocket();
android.updateMessages(roomId);
webkit.messageHandlers.updateMessages.postMessage({roomId});
socket.emit('exitRoom',roomId);
socket.emit('joinRoom', roomId, roomName, function() {
});
......@@ -1256,6 +1266,7 @@ CHAT_UI.removeFavoriteUser = function(shopMemberId) {
$('#userNameCard').modal('hide');
$('#myNameCard').modal('hide');
android.removeFavoriteUser(shopMemberId);
webkit.messageHandlers.removeFavoriteUser.postMessage({shopMemberId});
$('.shopmember_'+shopMemberId).removeClass('active');
$('.shopmember_'+shopMemberId).addClass('disable');
CHAT_UI.dismissLoadingIndicator();
......@@ -1266,6 +1277,7 @@ CHAT_UI.insertFavoriteUser = function(shopMemberId) {
$('#userNameCard').modal('hide');
$('#myNameCard').modal('hide');
android.addFavoriteUser(shopMemberId);
webkit.messageHandlers.addFavoriteUser.postMessage({shopMemberId});
$('.shopmember_'+shopMemberId).removeClass('disable');
$('.shopmember_'+shopMemberId).addClass('active');
CHAT_UI.dismissLoadingIndicator();
......@@ -1274,6 +1286,7 @@ CHAT_UI.insertFavoriteUser = function(shopMemberId) {
CHAT_UI.removeFavoriteGroup = function(groupId) {
CHAT_UI.showLoadingIndicator();
android.removeFavoriteGroup(groupId);
webkit.messageHandlers.removeFavoriteGroup.postMessage({groupId});
$('.group_'+groupId).removeClass('active');
$('.group_'+groupId).addClass('disable');
CHAT_UI.dismissLoadingIndicator();
......@@ -1282,6 +1295,7 @@ CHAT_UI.removeFavoriteGroup = function(groupId) {
CHAT_UI.insertFavoriteGroup = function(groupId) {
CHAT_UI.showLoadingIndicator();
android.addFavoriteGroup(groupId);
webkit.messageHandlers.addFavoriteGroup.postMessage({groupId});
$('.group_'+groupId).removeClass('disable');
$('.group_'+groupId).addClass('active');
CHAT_UI.dismissLoadingIndicator();
......@@ -1303,6 +1317,7 @@ CHAT_UI.refreshAllGroupSearch = function(groupId) {
//オンライン状態であればサーバから情報更新。
if (IS_ONLINE == 'true') {
android.updateGroupInfo(groupId);
webkit.messageHandlers.updateGroupInfo.postMessage({groupId});
}
//画面エリアを初期化。
......@@ -1393,6 +1408,7 @@ CHAT_UI.startChat = function(userShopMemberId,userName) {
// 参加ユーザ名でルーム名を生成
let newRoomName = CHAT.globalLoginParameter.loginId + ',' +userName;
android.createChatRoom(chatRoomType.DM, userIdList.join(','),newRoomName);
webkit.messageHandlers.createChatRoom.postMessage({"roomType": chatRoomType.DM, "userIdList": userIdList.join(','), "roomName": newRoomName});
CHAT_UI.hideNamecard(nameCardAreaId.USER);
};
......
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