|
|
@ -1805,7 +1805,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
.controller('PhotoModalController', function ($q, $scope, $rootScope, $modalInstance, AppPhotosManager, AppMessagesManager, AppPeersManager, PeersSelectService, ErrorService) { |
|
|
|
.controller('PhotoModalController', function ($q, $scope, $rootScope, $modalInstance, AppPhotosManager, AppMessagesManager, AppPeersManager, AppWebPagesManager, PeersSelectService, ErrorService) { |
|
|
|
|
|
|
|
|
|
|
|
$scope.photo = AppPhotosManager.wrapForFull($scope.photoID); |
|
|
|
$scope.photo = AppPhotosManager.wrapForFull($scope.photoID); |
|
|
|
$scope.nav = {}; |
|
|
|
$scope.nav = {}; |
|
|
@ -1861,6 +1861,78 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
|
|
|
|
|
|
|
|
updatePrevNext(); |
|
|
|
updatePrevNext(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function preloadPhotos (sign) { |
|
|
|
|
|
|
|
// var preloadOffsets = sign < 0 ? [-1,-2,1,-3,2] : [1,2,-1,3,-2];
|
|
|
|
|
|
|
|
var preloadOffsets = sign < 0 ? [-1,-2] : [1,2]; |
|
|
|
|
|
|
|
var index = list.indexOf($scope.messageID); |
|
|
|
|
|
|
|
angular.forEach(preloadOffsets, function (offset) { |
|
|
|
|
|
|
|
var messageID = list[index + offset]; |
|
|
|
|
|
|
|
if (messageID !== undefined && preloaded[messageID] === undefined) { |
|
|
|
|
|
|
|
preloaded[messageID] = true; |
|
|
|
|
|
|
|
var message = AppMessagesManager.getMessage(messageID); |
|
|
|
|
|
|
|
var photoID = message.media.photo.id; |
|
|
|
|
|
|
|
AppPhotosManager.preloadPhoto(photoID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function updatePrevNext (count) { |
|
|
|
|
|
|
|
var index = list.indexOf($scope.messageID); |
|
|
|
|
|
|
|
if (hasMore) { |
|
|
|
|
|
|
|
if (count) { |
|
|
|
|
|
|
|
$scope.count = Math.max(count, list.length); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$scope.count = list.length; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$scope.pos = $scope.count - index; |
|
|
|
|
|
|
|
$scope.nav.hasNext = index > 0; |
|
|
|
|
|
|
|
$scope.nav.hasPrev = hasMore || index < list.length - 1; |
|
|
|
|
|
|
|
$scope.canForward = $scope.canDelete = $scope.messageID > 0; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.nav.next = function () { |
|
|
|
|
|
|
|
if (!$scope.nav.hasNext) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
movePosition(-1); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.nav.prev = function () { |
|
|
|
|
|
|
|
if (!$scope.nav.hasPrev) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
movePosition(+1); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('history_delete', function (e, historyUpdate) { |
|
|
|
|
|
|
|
if (historyUpdate.peerID == peerID) { |
|
|
|
|
|
|
|
if (historyUpdate.msgs[$scope.messageID]) { |
|
|
|
|
|
|
|
if ($scope.nav.hasNext) { |
|
|
|
|
|
|
|
$scope.nav.next(); |
|
|
|
|
|
|
|
} else if ($scope.nav.hasPrev) { |
|
|
|
|
|
|
|
$scope.nav.prev(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return $modalInstance.dismiss(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var newList = []; |
|
|
|
|
|
|
|
for (var i = 0; i < list.length; i++) { |
|
|
|
|
|
|
|
if (!historyUpdate.msgs[list[i]]) { |
|
|
|
|
|
|
|
newList.push(list[i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
list = newList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($scope.webpageID) { |
|
|
|
|
|
|
|
$scope.webpage = AppWebPagesManager.wrapForHistory($scope.webpageID); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AppMessagesManager.getSearch(inputPeer, inputQuery, inputFilter, 0, 1000).then(function (searchCachedResult) { |
|
|
|
AppMessagesManager.getSearch(inputPeer, inputQuery, inputFilter, 0, 1000).then(function (searchCachedResult) { |
|
|
|
if (searchCachedResult.history.indexOf($scope.messageID) >= 0) { |
|
|
|
if (searchCachedResult.history.indexOf($scope.messageID) >= 0) { |
|
|
|
list = searchCachedResult.history; |
|
|
|
list = searchCachedResult.history; |
|
|
@ -1887,16 +1959,14 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
|
|
|
|
|
|
|
|
var messageID = list[index]; |
|
|
|
var messageID = list[index]; |
|
|
|
var message = AppMessagesManager.getMessage(messageID); |
|
|
|
var message = AppMessagesManager.getMessage(messageID); |
|
|
|
if (!message || |
|
|
|
var photoID = message && message.media && (message.media.photo && message.media.photo.id || message.media.webpage && message.media.webpage.photo && message.media.webpage.photo.id) |
|
|
|
!message.media || |
|
|
|
if (!photoID) { |
|
|
|
!message.media.photo || |
|
|
|
|
|
|
|
!message.media.photo.id) { |
|
|
|
|
|
|
|
console.error('Invalid photo message', index, list, messageID, message); |
|
|
|
console.error('Invalid photo message', index, list, messageID, message); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$scope.messageID = messageID; |
|
|
|
$scope.messageID = messageID; |
|
|
|
$scope.photoID = message.media.photo.id; |
|
|
|
$scope.photoID = photoID; |
|
|
|
$scope.photo = AppPhotosManager.wrapForFull($scope.photoID); |
|
|
|
$scope.photo = AppPhotosManager.wrapForFull($scope.photoID); |
|
|
|
|
|
|
|
|
|
|
|
preloaded[$scope.messageID] = true; |
|
|
|
preloaded[$scope.messageID] = true; |
|
|
@ -1911,21 +1981,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function preloadPhotos (sign) { |
|
|
|
|
|
|
|
// var preloadOffsets = sign < 0 ? [-1,-2,1,-3,2] : [1,2,-1,3,-2];
|
|
|
|
|
|
|
|
var preloadOffsets = sign < 0 ? [-1,-2] : [1,2]; |
|
|
|
|
|
|
|
var index = list.indexOf($scope.messageID); |
|
|
|
|
|
|
|
angular.forEach(preloadOffsets, function (offset) { |
|
|
|
|
|
|
|
var messageID = list[index + offset]; |
|
|
|
|
|
|
|
if (messageID !== undefined && preloaded[messageID] === undefined) { |
|
|
|
|
|
|
|
preloaded[messageID] = true; |
|
|
|
|
|
|
|
var message = AppMessagesManager.getMessage(messageID); |
|
|
|
|
|
|
|
var photoID = message.media.photo.id; |
|
|
|
|
|
|
|
AppPhotosManager.preloadPhoto(photoID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var loadingPromise = false; |
|
|
|
var loadingPromise = false; |
|
|
|
function loadMore () { |
|
|
|
function loadMore () { |
|
|
|
if (loadingPromise) return loadingPromise; |
|
|
|
if (loadingPromise) return loadingPromise; |
|
|
@ -1950,57 +2005,6 @@ angular.module('myApp.controllers', ['myApp.i18n']) |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function updatePrevNext (count) { |
|
|
|
|
|
|
|
var index = list.indexOf($scope.messageID); |
|
|
|
|
|
|
|
if (hasMore) { |
|
|
|
|
|
|
|
if (count) { |
|
|
|
|
|
|
|
$scope.count = Math.max(count, list.length); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$scope.count = list.length; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$scope.pos = $scope.count - index; |
|
|
|
|
|
|
|
$scope.nav.hasNext = index > 0; |
|
|
|
|
|
|
|
$scope.nav.hasPrev = hasMore || index < list.length - 1; |
|
|
|
|
|
|
|
$scope.canForward = $scope.canDelete = $scope.messageID > 0; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.nav.next = function () { |
|
|
|
|
|
|
|
if (!$scope.nav.hasNext) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
movePosition(-1); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.nav.prev = function () { |
|
|
|
|
|
|
|
if (!$scope.nav.hasPrev) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
movePosition(+1); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('history_delete', function (e, historyUpdate) { |
|
|
|
|
|
|
|
if (historyUpdate.peerID == peerID) { |
|
|
|
|
|
|
|
if (historyUpdate.msgs[$scope.messageID]) { |
|
|
|
|
|
|
|
if ($scope.nav.hasNext) { |
|
|
|
|
|
|
|
$scope.nav.next(); |
|
|
|
|
|
|
|
} else if ($scope.nav.hasPrev) { |
|
|
|
|
|
|
|
$scope.nav.prev(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return $modalInstance.dismiss(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var newList = []; |
|
|
|
|
|
|
|
for (var i = 0; i < list.length; i++) { |
|
|
|
|
|
|
|
if (!historyUpdate.msgs[list[i]]) { |
|
|
|
|
|
|
|
newList.push(list[i]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
list = newList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
.controller('UserpicModalController', function ($q, $scope, $rootScope, $modalInstance, MtpApiManager, AppPhotosManager, AppUsersManager, AppPeersManager, AppMessagesManager, ApiUpdatesManager, PeersSelectService, ErrorService) { |
|
|
|
.controller('UserpicModalController', function ($q, $scope, $rootScope, $modalInstance, MtpApiManager, AppPhotosManager, AppUsersManager, AppPeersManager, AppMessagesManager, ApiUpdatesManager, PeersSelectService, ErrorService) { |
|
|
|