Improved contacts updates
Also fixed scroll in emoji menu
This commit is contained in:
parent
11162b9f77
commit
1c4150d2ab
@ -1203,9 +1203,12 @@ a.mobile_modal_action .tg_checkbox_label {
|
|||||||
|
|
||||||
.emoji-menu {
|
.emoji-menu {
|
||||||
margin-left: -20px;
|
margin-left: -20px;
|
||||||
margin-top: -267px;
|
margin-top: -202px;
|
||||||
width: 262px;
|
width: 262px;
|
||||||
}
|
}
|
||||||
|
.emoji-menu .emoji-items-wrap {
|
||||||
|
height: 106px;
|
||||||
|
}
|
||||||
.emoji-menu .emoji-items a {
|
.emoji-menu .emoji-items a {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
}
|
}
|
||||||
|
@ -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,36 +676,40 @@ angular.module('myApp.controllers', [])
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showMoreContacts () {
|
||||||
|
contactsShown = true;
|
||||||
|
|
||||||
|
var curJump = ++jump;
|
||||||
|
AppUsersManager.getContacts($scope.search.query).then(function (contactsList) {
|
||||||
|
if (curJump != jump) return;
|
||||||
|
$scope.contacts = [];
|
||||||
|
angular.forEach(contactsList, function(userID) {
|
||||||
|
if (peersInDialogs[userID] === undefined) {
|
||||||
|
$scope.contacts.push({
|
||||||
|
userID: userID,
|
||||||
|
user: AppUsersManager.getUser(userID),
|
||||||
|
userPhoto: AppUsersManager.getUserPhoto(userID, 'User'),
|
||||||
|
peerString: AppUsersManager.getUserString(userID)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (contactsList.length) {
|
||||||
|
delete $scope.isEmpty.contacts;
|
||||||
|
} else if (!$scope.search.query) {
|
||||||
|
$scope.isEmpty.contacts = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$scope.$broadcast('ui_dialogs_append');
|
||||||
|
}
|
||||||
|
|
||||||
function showMoreDialogs () {
|
function showMoreDialogs () {
|
||||||
if (contactsShown && (!hasMore || !offset)) {
|
if (contactsShown && (!hasMore || !offset)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasMore && !$scope.search.messages && ($scope.search.query || !$scope.dialogs.length)) {
|
if (!hasMore && !$scope.search.messages && ($scope.search.query || !$scope.dialogs.length)) {
|
||||||
contactsShown = true;
|
showMoreContacts();
|
||||||
|
|
||||||
var curJump = ++jump;
|
|
||||||
AppUsersManager.getContacts($scope.search.query).then(function (contactsList) {
|
|
||||||
if (curJump != jump) return;
|
|
||||||
$scope.contacts = [];
|
|
||||||
angular.forEach(contactsList, function(userID) {
|
|
||||||
if (peersInDialogs[userID] === undefined) {
|
|
||||||
$scope.contacts.push({
|
|
||||||
userID: userID,
|
|
||||||
user: AppUsersManager.getUser(userID),
|
|
||||||
userPhoto: AppUsersManager.getUserPhoto(userID, 'User'),
|
|
||||||
peerString: AppUsersManager.getUserString(userID)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (contactsList.length) {
|
|
||||||
delete $scope.isEmpty.contacts;
|
|
||||||
} else if (!$scope.search.query) {
|
|
||||||
$scope.isEmpty.contacts = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$scope.$broadcast('ui_dialogs_append');
|
|
||||||
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 || '');
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -220,7 +220,7 @@ angular.module('myApp.services', [])
|
|||||||
onContactUpdated(foundUserID = importedContact.user_id, true);
|
onContactUpdated(foundUserID = importedContact.user_id, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
return foundUserID ? 1 : 0;
|
return foundUserID || false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ angular.module('myApp.services', [])
|
|||||||
|
|
||||||
function onContactUpdated (userID, isContact) {
|
function onContactUpdated (userID, isContact) {
|
||||||
if (angular.isArray(contactsList)) {
|
if (angular.isArray(contactsList)) {
|
||||||
var curPos = curIsContact = contactsList.indexOf(userID),
|
var curPos = curIsContact = contactsList.indexOf(parseInt(userID)),
|
||||||
curIsContact = curPos != -1;
|
curIsContact = curPos != -1;
|
||||||
|
|
||||||
if (isContact != curIsContact) {
|
if (isContact != curIsContact) {
|
||||||
@ -282,6 +282,7 @@ angular.module('myApp.services', [])
|
|||||||
} else {
|
} else {
|
||||||
contactsList.splice(curPos, 1);
|
contactsList.splice(curPos, 1);
|
||||||
}
|
}
|
||||||
|
$rootScope.$broadcast('contacts_update', userID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a ng-click="openGroup()">New Group</a></li>
|
<li><a ng-click="openGroup()">New Group</a></li>
|
||||||
<li><a ng-click="importContact()">New Contact</a></li>
|
<li><a ng-click="importContact()">New Contact</a></li>
|
||||||
<li><a ng-click="openContacts()">Contacts</a></li>
|
<li ng-if="!isEmpty.contacts"><a ng-click="openContacts()">Contacts</a></li>
|
||||||
<li><a ng-click="openSettings()">Settings</a></li>
|
<li><a ng-click="openSettings()">Settings</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<ul ng-if="!curDialog.peer && isLoggedIn" class="dropdown-menu">
|
<ul ng-if="!curDialog.peer && isLoggedIn" class="dropdown-menu">
|
||||||
<li><a ng-click="openGroup()">New Group</a></li>
|
<li><a ng-click="openGroup()">New Group</a></li>
|
||||||
<li><a ng-click="importContact()">New Contact</a></li>
|
<li><a ng-click="importContact()">New Contact</a></li>
|
||||||
<li><a ng-click="openContacts()">Contacts</a></li>
|
<li ng-if="!isEmpty.contacts"><a ng-click="openContacts()">Contacts</a></li>
|
||||||
<li><a ng-click="openSettings()">Settings</a></li>
|
<li><a ng-click="openSettings()">Settings</a></li>
|
||||||
<li><a ng-click="logOut()">Log Out</a></li>
|
<li><a ng-click="logOut()">Log Out</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
20
app/vendor/jquery.emojiarea/jquery.emojiarea.js
vendored
20
app/vendor/jquery.emojiarea/jquery.emojiarea.js
vendored
@ -484,15 +484,17 @@
|
|||||||
'<td><a class="emoji-menu-tab icon-car"></a></td>' +
|
'<td><a class="emoji-menu-tab icon-car"></a></td>' +
|
||||||
'<td><a class="emoji-menu-tab icon-grid"></a></td>' +
|
'<td><a class="emoji-menu-tab icon-grid"></a></td>' +
|
||||||
'</tr></table>').appendTo(this.$itemsTailWrap);
|
'</tr></table>').appendTo(this.$itemsTailWrap);
|
||||||
this.$itemsWrap = $('<div class="emoji-items-wrap nano"></div>').appendTo(this.$itemsTailWrap);
|
this.$itemsWrap = $('<div class="emoji-items-wrap nano mobile_scrollable_wrap"></div>').appendTo(this.$itemsTailWrap);
|
||||||
this.$items = $('<div class="emoji-items nano-content">').appendTo(this.$itemsWrap);
|
this.$items = $('<div class="emoji-items nano-content">').appendTo(this.$itemsWrap);
|
||||||
$('<div class="emoji-menu-tail">').appendTo(this.$menu);
|
$('<div class="emoji-menu-tail">').appendTo(this.$menu);
|
||||||
/*! MODIFICATION END */
|
/*! MODIFICATION END */
|
||||||
|
|
||||||
$body.append(this.$menu);
|
$body.append(this.$menu);
|
||||||
|
|
||||||
/*! MODIFICATION: Following line is added by Igor Zhukov, in order to add scrollbars to EmojiMenu */
|
/*! MODIFICATION: Following 3 lines were added by Igor Zhukov, in order to add scrollbars to EmojiMenu */
|
||||||
this.$itemsWrap.nanoScroller({preventPageScrolling: true, tabIndex: -1});
|
if (!Config.Mobile) {
|
||||||
|
this.$itemsWrap.nanoScroller({preventPageScrolling: true, tabIndex: -1});
|
||||||
|
}
|
||||||
|
|
||||||
$body.on('keydown', function(e) {
|
$body.on('keydown', function(e) {
|
||||||
if (e.keyCode === KEY_ESC || e.keyCode === KEY_TAB) {
|
if (e.keyCode === KEY_ESC || e.keyCode === KEY_TAB) {
|
||||||
@ -583,7 +585,9 @@
|
|||||||
});
|
});
|
||||||
this.currentCategory = category;
|
this.currentCategory = category;
|
||||||
this.load(category);
|
this.load(category);
|
||||||
this.$itemsWrap.nanoScroller({ scroll: 'top' });
|
if (!Config.Mobile) {
|
||||||
|
this.$itemsWrap.nanoScroller({ scroll: 'top' });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
/*! MODIFICATION END */
|
/*! MODIFICATION END */
|
||||||
|
|
||||||
@ -608,9 +612,11 @@
|
|||||||
var updateItems = function () {
|
var updateItems = function () {
|
||||||
self.$items.html(html.join(''));
|
self.$items.html(html.join(''));
|
||||||
|
|
||||||
setTimeout(function () {
|
if (!Config.Mobile) {
|
||||||
self.$itemsWrap.nanoScroller();
|
setTimeout(function () {
|
||||||
}, 100);
|
self.$itemsWrap.nanoScroller();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (category > 0) {
|
if (category > 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user