|
|
@ -216,7 +216,7 @@ angular.module('myApp.controllers', []) |
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('history_focus', function (e, peerData) { |
|
|
|
$scope.$on('history_focus', function (e, peerData) { |
|
|
|
$modalStack.dismissAll(); |
|
|
|
$modalStack.dismissAll(); |
|
|
|
if (peerData.peerString == $scope.curDialog.peer && !peerData.messageID) { |
|
|
|
if (peerData.peerString == $scope.curDialog.peer && peerData.messageID == $scope.curDialog.messageID) { |
|
|
|
$scope.$broadcast('ui_history_focus'); |
|
|
|
$scope.$broadcast('ui_history_focus'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$location.url('/im?p=' + peerData.peerString + (peerData.messageID ? '&m=' + peerData.messageID : '')); |
|
|
|
$location.url('/im?p=' + peerData.peerString + (peerData.messageID ? '&m=' + peerData.messageID : '')); |
|
|
@ -543,6 +543,7 @@ angular.module('myApp.controllers', []) |
|
|
|
|
|
|
|
|
|
|
|
$scope.history = []; |
|
|
|
$scope.history = []; |
|
|
|
$scope.mediaType = false; |
|
|
|
$scope.mediaType = false; |
|
|
|
|
|
|
|
$scope.skippedHistory = false; |
|
|
|
$scope.selectedMsgs = {}; |
|
|
|
$scope.selectedMsgs = {}; |
|
|
|
$scope.selectedCount = 0; |
|
|
|
$scope.selectedCount = 0; |
|
|
|
$scope.selectActions = false; |
|
|
|
$scope.selectActions = false; |
|
|
@ -557,6 +558,7 @@ angular.module('myApp.controllers', []) |
|
|
|
$scope.selectedFlush = selectedFlush; |
|
|
|
$scope.selectedFlush = selectedFlush; |
|
|
|
$scope.toggleEdit = toggleEdit; |
|
|
|
$scope.toggleEdit = toggleEdit; |
|
|
|
$scope.toggleMedia = toggleMedia; |
|
|
|
$scope.toggleMedia = toggleMedia; |
|
|
|
|
|
|
|
$scope.returnToRecent = returnToRecent; |
|
|
|
$scope.showPeerInfo = showPeerInfo; |
|
|
|
$scope.showPeerInfo = showPeerInfo; |
|
|
|
|
|
|
|
|
|
|
|
var peerID, |
|
|
|
var peerID, |
|
|
@ -703,7 +705,7 @@ angular.module('myApp.controllers', []) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
minID = 0; |
|
|
|
minID = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
hasLess = minID > 0; |
|
|
|
$scope.skippedHistory = hasLess = minID > 0; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -737,9 +739,11 @@ angular.module('myApp.controllers', []) |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function loadHistory () { |
|
|
|
function loadHistory (forceRecent) { |
|
|
|
|
|
|
|
$scope.missedCount = 0; |
|
|
|
|
|
|
|
|
|
|
|
hasMore = false; |
|
|
|
hasMore = false; |
|
|
|
hasLess = false; |
|
|
|
$scope.skippedHistory = hasLess = false; |
|
|
|
maxID = 0; |
|
|
|
maxID = 0; |
|
|
|
minID = 0; |
|
|
|
minID = 0; |
|
|
|
|
|
|
|
|
|
|
@ -750,6 +754,9 @@ angular.module('myApp.controllers', []) |
|
|
|
limit = 5; |
|
|
|
limit = 5; |
|
|
|
backLimit = 5; |
|
|
|
backLimit = 5; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if (forceRecent) { |
|
|
|
|
|
|
|
limit = 10; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var curJump = ++jump, |
|
|
|
var curJump = ++jump, |
|
|
|
inputMediaFilter = $scope.mediaType && {_: inputMediaFilters[$scope.mediaType]}, |
|
|
|
inputMediaFilter = $scope.mediaType && {_: inputMediaFilters[$scope.mediaType]}, |
|
|
@ -762,12 +769,12 @@ angular.module('myApp.controllers', []) |
|
|
|
getMessagesPromise.then(function (historyResult) { |
|
|
|
getMessagesPromise.then(function (historyResult) { |
|
|
|
if (curJump != jump) return; |
|
|
|
if (curJump != jump) return; |
|
|
|
|
|
|
|
|
|
|
|
minID = maxID && historyResult.history.indexOf(maxID)>= backLimit - 1 |
|
|
|
minID = (historyResult.unreadSkip || maxID && historyResult.history.indexOf(maxID) >= backLimit - 1) |
|
|
|
? historyResult.history[0] |
|
|
|
? historyResult.history[0] |
|
|
|
: 0; |
|
|
|
: 0; |
|
|
|
maxID = historyResult.history[historyResult.history.length - 1]; |
|
|
|
maxID = historyResult.history[historyResult.history.length - 1]; |
|
|
|
|
|
|
|
|
|
|
|
hasLess = minID > 0; |
|
|
|
$scope.skippedHistory = hasLess = minID > 0; |
|
|
|
hasMore = historyResult.count === null || |
|
|
|
hasMore = historyResult.count === null || |
|
|
|
historyResult.history.length && historyResult.history.length < historyResult.count; |
|
|
|
historyResult.history.length && historyResult.history.length < historyResult.count; |
|
|
|
|
|
|
|
|
|
|
@ -782,13 +789,10 @@ angular.module('myApp.controllers', []) |
|
|
|
|
|
|
|
|
|
|
|
updateHistoryGroups(); |
|
|
|
updateHistoryGroups(); |
|
|
|
|
|
|
|
|
|
|
|
if (historyResult.unreadLimit) { |
|
|
|
if (historyResult.unreadOffset) { |
|
|
|
$scope.historyUnread = { |
|
|
|
$scope.historyUnreadAfter = historyResult.history[historyResult.unreadOffset - 1]; |
|
|
|
beforeID: historyResult.history[historyResult.unreadLimit - 1], |
|
|
|
|
|
|
|
count: historyResult.unreadLimit |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$scope.historyUnread = {}; |
|
|
|
$scope.historyUnreadAfter = {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$scope.historyFocus = $scope.curDialog.messageID || 0; |
|
|
|
$scope.historyFocus = $scope.curDialog.messageID || 0; |
|
|
@ -924,14 +928,23 @@ angular.module('myApp.controllers', []) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function toggleMedia (mediaType) { |
|
|
|
function toggleMedia (mediaType) { |
|
|
|
if (mediaType) { |
|
|
|
|
|
|
|
$scope.missedCount = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$scope.mediaType = mediaType || false; |
|
|
|
$scope.mediaType = mediaType || false; |
|
|
|
$scope.history = []; |
|
|
|
$scope.history = []; |
|
|
|
loadHistory(); |
|
|
|
loadHistory(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function returnToRecent () { |
|
|
|
|
|
|
|
if ($scope.mediaType) { |
|
|
|
|
|
|
|
toggleMedia(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if ($scope.curDialog.messageID) { |
|
|
|
|
|
|
|
$rootScope.$broadcast('history_focus', {peerString: $scope.curDialog.peer}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
loadHistory(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function showPeerInfo () { |
|
|
|
function showPeerInfo () { |
|
|
|
if ($scope.curDialog.peerID > 0) { |
|
|
|
if ($scope.curDialog.peerID > 0) { |
|
|
|
$rootScope.openUser($scope.curDialog.peerID) |
|
|
|
$rootScope.openUser($scope.curDialog.peerID) |
|
|
@ -947,17 +960,9 @@ angular.module('myApp.controllers', []) |
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('history_append', function (e, addedMessage) { |
|
|
|
$scope.$on('history_append', function (e, addedMessage) { |
|
|
|
if (addedMessage.peerID == $scope.curDialog.peerID) { |
|
|
|
if (addedMessage.peerID == $scope.curDialog.peerID) { |
|
|
|
if (minID) { |
|
|
|
if ($scope.mediaType || $scope.skippedHistory) { |
|
|
|
if (addedMessage.my) { |
|
|
|
|
|
|
|
$rootScope.$broadcast('history_focus', {peerString: $scope.curDialog.peer}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$scope.missedCount++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ($scope.mediaType) { |
|
|
|
|
|
|
|
if (addedMessage.my) { |
|
|
|
if (addedMessage.my) { |
|
|
|
toggleMedia(); |
|
|
|
returnToRecent(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$scope.missedCount++; |
|
|
|
$scope.missedCount++; |
|
|
|
} |
|
|
|
} |
|
|
@ -973,8 +978,6 @@ angular.module('myApp.controllers', []) |
|
|
|
$scope.historyUnread = {}; |
|
|
|
$scope.historyUnread = {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
offset++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// console.log('append check', $rootScope.idle.isIDLE, addedMessage.peerID, $scope.curDialog.peerID);
|
|
|
|
// console.log('append check', $rootScope.idle.isIDLE, addedMessage.peerID, $scope.curDialog.peerID);
|
|
|
|
if (!$rootScope.idle.isIDLE) { |
|
|
|
if (!$rootScope.idle.isIDLE) { |
|
|
|
$timeout(function () { |
|
|
|
$timeout(function () { |
|
|
|