|
|
@ -373,7 +373,9 @@ angular.module('myApp.controllers', []) |
|
|
|
$scope.importContact = function () { |
|
|
|
$scope.importContact = function () { |
|
|
|
AppUsersManager.openImportContact().then(function (foundContact) { |
|
|
|
AppUsersManager.openImportContact().then(function (foundContact) { |
|
|
|
if (foundContact) { |
|
|
|
if (foundContact) { |
|
|
|
$scope.$broadcast('contact_imported'); |
|
|
|
$rootScope.$broadcast('history_focus', { |
|
|
|
|
|
|
|
peerString: AppUsersManager.getUserString(foundContact) |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -496,6 +498,14 @@ angular.module('myApp.controllers', []) |
|
|
|
offset++; |
|
|
|
offset++; |
|
|
|
} |
|
|
|
} |
|
|
|
$scope.dialogs.unshift(wrappedDialog); |
|
|
|
$scope.dialogs.unshift(wrappedDialog); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!peersInDialogs[dialog.peerID]) { |
|
|
|
|
|
|
|
peersInDialogs[dialog.peerID] = true; |
|
|
|
|
|
|
|
if (contactsShown) { |
|
|
|
|
|
|
|
showMoreContacts(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('dialog_flush', function (e, dialog) { |
|
|
|
$scope.$on('dialog_flush', function (e, dialog) { |
|
|
@ -518,12 +528,6 @@ angular.module('myApp.controllers', []) |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('contact_imported', function () { |
|
|
|
|
|
|
|
if (contactsShown) { |
|
|
|
|
|
|
|
loadDialogs(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var prevMessages = false; |
|
|
|
var prevMessages = false; |
|
|
|
$scope.$watchCollection('search', function () { |
|
|
|
$scope.$watchCollection('search', function () { |
|
|
|
if ($scope.search.messages != prevMessages) { |
|
|
|
if ($scope.search.messages != prevMessages) { |
|
|
@ -555,13 +559,15 @@ angular.module('myApp.controllers', []) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$scope.importPhonebook = function () { |
|
|
|
$scope.importPhonebook = function () { |
|
|
|
PhonebookContactsService.openPhonebookImport().result.then(function (foundContacts) { |
|
|
|
PhonebookContactsService.openPhonebookImport(); |
|
|
|
if (contactsShown && foundContacts.length) { |
|
|
|
|
|
|
|
loadDialogs(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.$on('contacts_update', function () { |
|
|
|
|
|
|
|
if (contactsShown) { |
|
|
|
|
|
|
|
showMoreContacts(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$scope.searchClear = function () { |
|
|
|
$scope.searchClear = function () { |
|
|
|
$scope.search.query = ''; |
|
|
|
$scope.search.query = ''; |
|
|
|
$scope.search.messages = false; |
|
|
|
$scope.search.messages = false; |
|
|
@ -630,14 +636,6 @@ angular.module('myApp.controllers', []) |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$scope.importPhonebook = function () { |
|
|
|
|
|
|
|
PhonebookContactsService.openPhonebookImport().result.then(function (foundContacts) { |
|
|
|
|
|
|
|
if (contactsShown && foundContacts.length) { |
|
|
|
|
|
|
|
loadDialogs(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadDialogs (force) { |
|
|
|
function loadDialogs (force) { |
|
|
|
offset = 0; |
|
|
|
offset = 0; |
|
|
|
maxID = 0; |
|
|
|
maxID = 0; |
|
|
@ -669,6 +667,7 @@ angular.module('myApp.controllers', []) |
|
|
|
AppMessagesManager.getDialogs('', maxID, 100); |
|
|
|
AppMessagesManager.getDialogs('', maxID, 100); |
|
|
|
if (!dialogsResult.dialogs.length) { |
|
|
|
if (!dialogsResult.dialogs.length) { |
|
|
|
$scope.isEmpty.dialogs = true; |
|
|
|
$scope.isEmpty.dialogs = true; |
|
|
|
|
|
|
|
showMoreDialogs(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
showMoreDialogs(); |
|
|
|
showMoreDialogs(); |
|
|
@ -677,12 +676,7 @@ angular.module('myApp.controllers', []) |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function showMoreDialogs () { |
|
|
|
function showMoreContacts () { |
|
|
|
if (contactsShown && (!hasMore || !offset)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasMore && !$scope.search.messages && ($scope.search.query || !$scope.dialogs.length)) { |
|
|
|
|
|
|
|
contactsShown = true; |
|
|
|
contactsShown = true; |
|
|
|
|
|
|
|
|
|
|
|
var curJump = ++jump; |
|
|
|
var curJump = ++jump; |
|
|
@ -707,6 +701,15 @@ angular.module('myApp.controllers', []) |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
$scope.$broadcast('ui_dialogs_append'); |
|
|
|
$scope.$broadcast('ui_dialogs_append'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function showMoreDialogs () { |
|
|
|
|
|
|
|
if (contactsShown && (!hasMore || !offset)) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!hasMore && !$scope.search.messages && ($scope.search.query || !$scope.dialogs.length)) { |
|
|
|
|
|
|
|
showMoreContacts(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2285,6 +2288,9 @@ angular.module('myApp.controllers', []) |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$scope.$watch('search.query', updateContacts); |
|
|
|
$scope.$watch('search.query', updateContacts); |
|
|
|
|
|
|
|
$scope.$on('contacts_update', function () { |
|
|
|
|
|
|
|
updateContacts($scope.search && $scope.search.query || ''); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$scope.toggleEdit = function (enabled) { |
|
|
|
$scope.toggleEdit = function (enabled) { |
|
|
|
$scope.action = enabled ? 'edit' : ''; |
|
|
|
$scope.action = enabled ? 'edit' : ''; |
|
|
@ -2325,17 +2331,13 @@ angular.module('myApp.controllers', []) |
|
|
|
selectedUserIDs.push(userID); |
|
|
|
selectedUserIDs.push(userID); |
|
|
|
}); |
|
|
|
}); |
|
|
|
AppUsersManager.deleteContacts(selectedUserIDs).then(function () { |
|
|
|
AppUsersManager.deleteContacts(selectedUserIDs).then(function () { |
|
|
|
resetSelected(); |
|
|
|
$scope.toggleEdit(false); |
|
|
|
$scope.action = ''; |
|
|
|
|
|
|
|
updateContacts($scope.search.query); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$scope.importContact = function () { |
|
|
|
$scope.importContact = function () { |
|
|
|
AppUsersManager.openImportContact().then(function () { |
|
|
|
AppUsersManager.openImportContact(); |
|
|
|
updateContacts($scope.search && $scope.search.query || ''); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|