Implemented messages grouping #177
This commit is contained in:
parent
2189ed1ea2
commit
9528abdb40
@ -951,6 +951,24 @@ a.im_dialog:hover .im_dialog_date {
|
|||||||
.non_osx .im_message_author {
|
.non_osx .im_message_author {
|
||||||
font-size: 12px;
|
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_from_photo,
|
||||||
.im_message_contact_photo {
|
.im_message_contact_photo {
|
||||||
|
@ -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 () {
|
function showMoreHistory () {
|
||||||
if (!hasMore || !offset) {
|
if (!hasMore || !offset) {
|
||||||
return;
|
return;
|
||||||
@ -464,6 +490,8 @@ angular.module('myApp.controllers', [])
|
|||||||
$scope.history.unshift(AppMessagesManager.wrapForHistory(id));
|
$scope.history.unshift(AppMessagesManager.wrapForHistory(id));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateHistoryGroups(historyResult.history.length);
|
||||||
|
|
||||||
$scope.$broadcast('ui_history_prepend');
|
$scope.$broadcast('ui_history_prepend');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -497,6 +525,8 @@ angular.module('myApp.controllers', [])
|
|||||||
});
|
});
|
||||||
$scope.history.reverse();
|
$scope.history.reverse();
|
||||||
|
|
||||||
|
updateHistoryGroups();
|
||||||
|
|
||||||
if (historyResult.unreadLimit) {
|
if (historyResult.unreadLimit) {
|
||||||
$scope.historyUnread = {
|
$scope.historyUnread = {
|
||||||
beforeID: historyResult.history[historyResult.unreadLimit - 1],
|
beforeID: historyResult.history[historyResult.unreadLimit - 1],
|
||||||
@ -636,6 +666,7 @@ angular.module('myApp.controllers', [])
|
|||||||
// console.log('append', addedMessage);
|
// console.log('append', addedMessage);
|
||||||
// console.trace();
|
// console.trace();
|
||||||
$scope.history.push(AppMessagesManager.wrapForHistory(addedMessage.messageID));
|
$scope.history.push(AppMessagesManager.wrapForHistory(addedMessage.messageID));
|
||||||
|
updateHistoryGroups(-3);
|
||||||
$scope.typing = {};
|
$scope.typing = {};
|
||||||
$scope.$broadcast('ui_history_append', {my: addedMessage.my});
|
$scope.$broadcast('ui_history_append', {my: addedMessage.my});
|
||||||
if (addedMessage.my) {
|
if (addedMessage.my) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
</ng-pluralize>
|
</ng-pluralize>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="im_message_outer_wrap" ng-class="{im_message_selected: selectedMsgs[historyMessage.id]}" ng-click="toggleMessage(historyMessage.id, $event.target)">
|
<div class="im_message_outer_wrap" ng-class="{im_message_selected: selectedMsgs[historyMessage.id], im_message_grouped: historyMessage.grouped}" ng-click="toggleMessage(historyMessage.id, $event.target)">
|
||||||
|
|
||||||
|
|
||||||
<div class="im_message_wrap clearfix" bindonce>
|
<div class="im_message_wrap clearfix" bindonce>
|
||||||
|
Loading…
Reference in New Issue
Block a user