|
|
@ -11,12 +11,19 @@ |
|
|
|
|
|
|
|
|
|
|
|
angular.module('myApp.services', []) |
|
|
|
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 = {}, |
|
|
|
var users = {}, |
|
|
|
cachedPhotoLocations = {}, |
|
|
|
cachedPhotoLocations = {}, |
|
|
|
contactsFillPromise, |
|
|
|
contactsFillPromise, |
|
|
|
contactsList, |
|
|
|
contactsList, |
|
|
|
contactsIndex = SearchIndexManager.createIndex(); |
|
|
|
contactsIndex = SearchIndexManager.createIndex(), |
|
|
|
|
|
|
|
serverTimeOffset = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Storage.get('server_time_offset').then(function (to) { |
|
|
|
|
|
|
|
if (to) { |
|
|
|
|
|
|
|
serverTimeOffset = to; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function fillContacts () { |
|
|
|
function fillContacts () { |
|
|
|
if (contactsFillPromise) { |
|
|
|
if (contactsFillPromise) { |
|
|
@ -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) { |
|
|
|
function wrapForFull (id) { |
|
|
|
var user = getUser(id); |
|
|
|
var user = getUser(id); |
|
|
|
|
|
|
|
|
|
|
@ -309,6 +327,8 @@ angular.module('myApp.services', []) |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setInterval(updateUsersStatuses, 60000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
getContacts: getContacts, |
|
|
|
getContacts: getContacts, |
|
|
@ -3768,7 +3788,6 @@ var regexAlphaNumericChars = "0-9\.\_" + regexAlphaChars; |
|
|
|
if (typeof ver2 !== 'string') { |
|
|
|
if (typeof ver2 !== 'string') { |
|
|
|
ver2 = ''; |
|
|
|
ver2 = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
// console.log('ss', ver1, ver2);
|
|
|
|
|
|
|
|
ver1 = ver1.replace(/^\s+|\s+$/g, '').split('.'); |
|
|
|
ver1 = ver1.replace(/^\s+|\s+$/g, '').split('.'); |
|
|
|
ver2 = ver2.replace(/^\s+|\s+$/g, '').split('.'); |
|
|
|
ver2 = ver2.replace(/^\s+|\s+$/g, '').split('.'); |
|
|
|
|
|
|
|
|
|
|
|