|
|
@ -566,7 +566,7 @@ angular.module('myApp.controllers', []) |
|
|
|
if (searchMessages) { |
|
|
|
if (searchMessages) { |
|
|
|
searchTimeoutPromise = force ? $q.when() : $timeout(angular.noop, 500); |
|
|
|
searchTimeoutPromise = force ? $q.when() : $timeout(angular.noop, 500); |
|
|
|
promise = searchTimeoutPromise.then(function () { |
|
|
|
promise = searchTimeoutPromise.then(function () { |
|
|
|
return AppMessagesManager.getSearch({_: 'inputPeerEmpty'}, $scope.search.query, {_: 'inputMessagesFilterEmpty'}, maxID) |
|
|
|
return AppMessagesManager.getSearch({_: 'inputPeerEmpty'}, $scope.search.query, {_: 'inputMessagesFilterEmpty'}, maxID); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
promise = AppMessagesManager.getDialogs($scope.search.query, maxID); |
|
|
|
promise = AppMessagesManager.getDialogs($scope.search.query, maxID); |
|
|
@ -585,7 +585,7 @@ angular.module('myApp.controllers', []) |
|
|
|
dialogs.push({ |
|
|
|
dialogs.push({ |
|
|
|
peerID: peerID, |
|
|
|
peerID: peerID, |
|
|
|
top_message: messageID, |
|
|
|
top_message: messageID, |
|
|
|
unread_count: 0 |
|
|
|
unread_count: -1 |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -644,7 +644,8 @@ angular.module('myApp.controllers', []) |
|
|
|
|
|
|
|
|
|
|
|
angular.forEach(dialogsResult.dialogs, function (dialog) { |
|
|
|
angular.forEach(dialogsResult.dialogs, function (dialog) { |
|
|
|
peersInDialogs[dialog.peerID] = true; |
|
|
|
peersInDialogs[dialog.peerID] = true; |
|
|
|
$scope.dialogs.push(AppMessagesManager.wrapForDialog(dialog.top_message, dialog.unread_count)); |
|
|
|
var wrappedDialog = AppMessagesManager.wrapForDialog(dialog.top_message, dialog.unread_count); |
|
|
|
|
|
|
|
$scope.dialogs.push(wrappedDialog); |
|
|
|
}); |
|
|
|
}); |
|
|
|
delete $scope.isEmpty.dialogs; |
|
|
|
delete $scope.isEmpty.dialogs; |
|
|
|
} |
|
|
|
} |
|
|
@ -764,7 +765,11 @@ angular.module('myApp.controllers', []) |
|
|
|
}, |
|
|
|
}, |
|
|
|
jump = 0, |
|
|
|
jump = 0, |
|
|
|
moreJump = 0, |
|
|
|
moreJump = 0, |
|
|
|
lessJump = 0; |
|
|
|
moreActive = false, |
|
|
|
|
|
|
|
morePending = false, |
|
|
|
|
|
|
|
lessJump = 0, |
|
|
|
|
|
|
|
lessActive = false, |
|
|
|
|
|
|
|
lessPending = false; |
|
|
|
|
|
|
|
|
|
|
|
function applyDialogSelect (newDialog, oldDialog) { |
|
|
|
function applyDialogSelect (newDialog, oldDialog) { |
|
|
|
var newPeer = newDialog.peer || $scope.curDialog.peer || ''; |
|
|
|
var newPeer = newDialog.peer || $scope.curDialog.peer || ''; |
|
|
@ -867,12 +872,14 @@ angular.module('myApp.controllers', []) |
|
|
|
found = false, |
|
|
|
found = false, |
|
|
|
history = historiesQueueFind(); |
|
|
|
history = historiesQueueFind(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (history) { |
|
|
|
for (i = 0; i < history.messages.length; i++) { |
|
|
|
for (i = 0; i < history.messages.length; i++) { |
|
|
|
if ($scope.curDialog.messageID == history.messages[i].id) { |
|
|
|
if ($scope.curDialog.messageID == history.messages[i].id) { |
|
|
|
found = true; |
|
|
|
found = true; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (found) { |
|
|
|
if (found) { |
|
|
|
$scope.historyUnread = {}; |
|
|
|
$scope.historyUnread = {}; |
|
|
@ -887,12 +894,19 @@ angular.module('myApp.controllers', []) |
|
|
|
if (!hasLess) { |
|
|
|
if (!hasLess) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (moreActive) { |
|
|
|
|
|
|
|
lessPending = true; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
lessPending = false; |
|
|
|
|
|
|
|
lessActive = true; |
|
|
|
|
|
|
|
|
|
|
|
var curJump = jump, |
|
|
|
var curJump = jump, |
|
|
|
curLessJump = ++lessJump, |
|
|
|
curLessJump = ++lessJump, |
|
|
|
limit = 0, |
|
|
|
limit = 0, |
|
|
|
backLimit = 20; |
|
|
|
backLimit = 20; |
|
|
|
AppMessagesManager.getHistory($scope.curDialog.inputPeer, minID, limit, backLimit).then(function (historyResult) { |
|
|
|
AppMessagesManager.getHistory($scope.curDialog.inputPeer, minID, limit, backLimit).then(function (historyResult) { |
|
|
|
|
|
|
|
lessActive = false; |
|
|
|
if (curJump != jump || curLessJump != lessJump) return; |
|
|
|
if (curJump != jump || curLessJump != lessJump) return; |
|
|
|
|
|
|
|
|
|
|
|
var i, id; |
|
|
|
var i, id; |
|
|
@ -916,6 +930,10 @@ angular.module('myApp.controllers', []) |
|
|
|
minID = 0; |
|
|
|
minID = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
$scope.skippedHistory = hasLess = minID > 0; |
|
|
|
$scope.skippedHistory = hasLess = minID > 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (morePending) { |
|
|
|
|
|
|
|
showMoreHistory(); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -923,6 +941,12 @@ angular.module('myApp.controllers', []) |
|
|
|
if (!hasMore) { |
|
|
|
if (!hasMore) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (lessActive) { |
|
|
|
|
|
|
|
morePending = true; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
morePending = false; |
|
|
|
|
|
|
|
moreActive = true; |
|
|
|
|
|
|
|
|
|
|
|
var curJump = jump, |
|
|
|
var curJump = jump, |
|
|
|
curMoreJump = moreJump, |
|
|
|
curMoreJump = moreJump, |
|
|
@ -933,6 +957,7 @@ angular.module('myApp.controllers', []) |
|
|
|
: AppMessagesManager.getHistory($scope.curDialog.inputPeer, maxID, limit); |
|
|
|
: AppMessagesManager.getHistory($scope.curDialog.inputPeer, maxID, limit); |
|
|
|
|
|
|
|
|
|
|
|
getMessagesPromise.then(function (historyResult) { |
|
|
|
getMessagesPromise.then(function (historyResult) { |
|
|
|
|
|
|
|
moreActive = false; |
|
|
|
if (curJump != jump || curMoreJump != moreJump) return; |
|
|
|
if (curJump != jump || curMoreJump != moreJump) return; |
|
|
|
|
|
|
|
|
|
|
|
angular.forEach(historyResult.history, function (id) { |
|
|
|
angular.forEach(historyResult.history, function (id) { |
|
|
@ -950,6 +975,10 @@ angular.module('myApp.controllers', []) |
|
|
|
} |
|
|
|
} |
|
|
|
$scope.$broadcast('ui_history_prepend'); |
|
|
|
$scope.$broadcast('ui_history_prepend'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lessPending) { |
|
|
|
|
|
|
|
showLessHistory(); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -967,8 +996,8 @@ angular.module('myApp.controllers', []) |
|
|
|
|
|
|
|
|
|
|
|
if ($scope.curDialog.messageID) { |
|
|
|
if ($scope.curDialog.messageID) { |
|
|
|
maxID = parseInt($scope.curDialog.messageID); |
|
|
|
maxID = parseInt($scope.curDialog.messageID); |
|
|
|
limit = 5; |
|
|
|
limit = 10; |
|
|
|
backLimit = 5; |
|
|
|
backLimit = 10; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (forceRecent) { |
|
|
|
else if (forceRecent) { |
|
|
|
limit = 10; |
|
|
|
limit = 10; |
|
|
@ -977,6 +1006,11 @@ angular.module('myApp.controllers', []) |
|
|
|
limit = 20; |
|
|
|
limit = 20; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
moreActive = false; |
|
|
|
|
|
|
|
morePending = false; |
|
|
|
|
|
|
|
lessActive = false; |
|
|
|
|
|
|
|
lessPending = false; |
|
|
|
|
|
|
|
|
|
|
|
var curJump = ++jump, |
|
|
|
var curJump = ++jump, |
|
|
|
inputMediaFilter = $scope.historyFilter.mediaType && {_: inputMediaFilters[$scope.historyFilter.mediaType]}, |
|
|
|
inputMediaFilter = $scope.historyFilter.mediaType && {_: inputMediaFilters[$scope.historyFilter.mediaType]}, |
|
|
|
getMessagesPromise = inputMediaFilter |
|
|
|
getMessagesPromise = inputMediaFilter |
|
|
@ -1024,7 +1058,9 @@ angular.module('myApp.controllers', []) |
|
|
|
delete $scope.historyUnreadAfter; |
|
|
|
delete $scope.historyUnreadAfter; |
|
|
|
$scope.$broadcast('messages_unread_after'); |
|
|
|
$scope.$broadcast('messages_unread_after'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
onContentLoaded(function () { |
|
|
|
$scope.$broadcast('messages_focus', $scope.curDialog.messageID || 0); |
|
|
|
$scope.$broadcast('messages_focus', $scope.curDialog.messageID || 0); |
|
|
|
|
|
|
|
}) |
|
|
|
$scope.$broadcast('ui_history_change'); |
|
|
|
$scope.$broadcast('ui_history_change'); |
|
|
|
|
|
|
|
|
|
|
|
AppMessagesManager.readHistory($scope.curDialog.inputPeer); |
|
|
|
AppMessagesManager.readHistory($scope.curDialog.inputPeer); |
|
|
|