|
|
@ -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) { |
|
|
|