|
|
|
@ -11,12 +11,19 @@
@@ -11,12 +11,19 @@
|
|
|
|
|
|
|
|
|
|
angular.module('myApp.services', []) |
|
|
|
|
|
|
|
|
|
.service('AppUsersManager', function ($rootScope, $modal, $modalStack, $filter, $q, MtpApiFileManager, MtpApiManager, RichTextProcessor, SearchIndexManager, ErrorService) { |
|
|
|
|
.service('AppUsersManager', function ($rootScope, $modal, $modalStack, $filter, $q, MtpApiFileManager, MtpApiManager, RichTextProcessor, SearchIndexManager, ErrorService, Storage) { |
|
|
|
|
var users = {}, |
|
|
|
|
cachedPhotoLocations = {}, |
|
|
|
|
contactsFillPromise, |
|
|
|
|
contactsList, |
|
|
|
|
contactsIndex = SearchIndexManager.createIndex(); |
|
|
|
|
contactsIndex = SearchIndexManager.createIndex(), |
|
|
|
|
serverTimeOffset = 0; |
|
|
|
|
|
|
|
|
|
Storage.get('server_time_offset').then(function (to) { |
|
|
|
|
if (to) { |
|
|
|
|
serverTimeOffset = to; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
function fillContacts () { |
|
|
|
|
if (contactsFillPromise) { |
|
|
|
@ -152,6 +159,17 @@ angular.module('myApp.services', [])
@@ -152,6 +159,17 @@ angular.module('myApp.services', [])
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function updateUsersStatuses () { |
|
|
|
|
var timestampNow = tsNow(true) + serverTimeOffset; |
|
|
|
|
angular.forEach(users, function (user) { |
|
|
|
|
if (user.status && user.status._ == 'userStatusOnline' && |
|
|
|
|
user.status.expires > timestampNow) { |
|
|
|
|
user.status = {_: 'userStatusOffline', was_online: user.status.expires}; |
|
|
|
|
$rootScope.$broadcast('user_update', user.id); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function wrapForFull (id) { |
|
|
|
|
var user = getUser(id); |
|
|
|
|
|
|
|
|
@ -309,6 +327,8 @@ angular.module('myApp.services', [])
@@ -309,6 +327,8 @@ angular.module('myApp.services', [])
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
setInterval(updateUsersStatuses, 60000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
getContacts: getContacts, |
|
|
|
@ -3768,7 +3788,6 @@ var regexAlphaNumericChars = "0-9\.\_" + regexAlphaChars;
@@ -3768,7 +3788,6 @@ var regexAlphaNumericChars = "0-9\.\_" + regexAlphaChars;
|
|
|
|
|
if (typeof ver2 !== 'string') { |
|
|
|
|
ver2 = ''; |
|
|
|
|
} |
|
|
|
|
// console.log('ss', ver1, ver2);
|
|
|
|
|
ver1 = ver1.replace(/^\s+|\s+$/g, '').split('.'); |
|
|
|
|
ver2 = ver2.replace(/^\s+|\s+$/g, '').split('.'); |
|
|
|
|
|
|
|
|
|