diff --git a/app/css/app.css b/app/css/app.css index 990d34a7..710d04af 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -951,6 +951,24 @@ a.im_dialog:hover .im_dialog_date { .non_osx .im_message_author { font-size: 12px; } +.im_message_grouped .im_message_from_photo, +.im_message_grouped .im_message_author { + display: none; +} +.im_message_grouped .im_message_body { + margin-left: 46px; +} +.im_message_grouped .im_content_message_select_area { + height: 34px; +} +.im_message_grouped .icon-select-tick { + margin-top: 4px; +} +.im_message_grouped .icon-message-status { + display: none; + margin-top: 5px; + margin-left: 24px; +} .im_message_from_photo, .im_message_contact_photo { diff --git a/app/js/controllers.js b/app/js/controllers.js index de5c2849..84598e89 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -441,6 +441,32 @@ angular.module('myApp.controllers', []) } } + function updateHistoryGroups (limit) { + var start = 0, + end = $scope.history.length, + i, curMessage, prevMessage; + + if (limit > 0) { + end = limit; + } else if (limit < 0) { + start = end + limit; + } + + for (i = start; i < end; i++) { + curMessage = $scope.history[i]; + if (prevMessage) console.log(dT(), curMessage.from_id == prevMessage.from_id, curMessage.date - prevMessage.date); + if (prevMessage && + curMessage.from_id == prevMessage.from_id && + curMessage.date < prevMessage.date + 30 && + curMessage.message && curMessage.message.length < 30) { + curMessage.grouped = true; + } else if (!start) { + delete curMessage.grouped; + } + prevMessage = curMessage; + } + } + function showMoreHistory () { if (!hasMore || !offset) { return; @@ -464,6 +490,8 @@ angular.module('myApp.controllers', []) $scope.history.unshift(AppMessagesManager.wrapForHistory(id)); }); + updateHistoryGroups(historyResult.history.length); + $scope.$broadcast('ui_history_prepend'); }); } @@ -497,6 +525,8 @@ angular.module('myApp.controllers', []) }); $scope.history.reverse(); + updateHistoryGroups(); + if (historyResult.unreadLimit) { $scope.historyUnread = { beforeID: historyResult.history[historyResult.unreadLimit - 1], @@ -636,6 +666,7 @@ angular.module('myApp.controllers', []) // console.log('append', addedMessage); // console.trace(); $scope.history.push(AppMessagesManager.wrapForHistory(addedMessage.messageID)); + updateHistoryGroups(-3); $scope.typing = {}; $scope.$broadcast('ui_history_append', {my: addedMessage.my}); if (addedMessage.my) { diff --git a/app/partials/message.html b/app/partials/message.html index 878bb0f1..2212afbc 100644 --- a/app/partials/message.html +++ b/app/partials/message.html @@ -4,7 +4,7 @@ -
+