parent
b00dd96a5c
commit
da6b82ae8f
@ -1445,7 +1445,6 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
|
|
||||||
function link($scope, element, attrs) {
|
function link($scope, element, attrs) {
|
||||||
|
|
||||||
console.log(dT(), 'bg', attrs.myCustomBackground);
|
|
||||||
$('html').css({background: attrs.myCustomBackground});
|
$('html').css({background: attrs.myCustomBackground});
|
||||||
|
|
||||||
$scope.$on('$destroy', function () {
|
$scope.$on('$destroy', function () {
|
||||||
@ -1603,14 +1602,25 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
|
|
||||||
.directive('myUserStatus', function ($filter, $rootScope, AppUsersManager) {
|
.directive('myUserStatus', function ($filter, $rootScope, AppUsersManager) {
|
||||||
|
|
||||||
var statusFilter = $filter('userStatus');
|
var statusFilter = $filter('userStatus'),
|
||||||
|
ind = 0,
|
||||||
|
statuses = {};
|
||||||
|
|
||||||
|
setInterval(updateAll, 90000);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
link: link
|
link: link
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function updateAll () {
|
||||||
|
angular.forEach(statuses, function (update) {
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function link($scope, element, attrs) {
|
function link($scope, element, attrs) {
|
||||||
var userID,
|
var userID,
|
||||||
|
curInd = ind++,
|
||||||
update = function () {
|
update = function () {
|
||||||
var user = AppUsersManager.getUser(userID);
|
var user = AppUsersManager.getUser(userID);
|
||||||
element
|
element
|
||||||
@ -1627,6 +1637,10 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
statuses[curInd] = update;
|
||||||
|
$scope.$on('$destroy', function () {
|
||||||
|
delete statuses[curInd];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -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('.');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user