Improved statuses updates
This commit is contained in:
parent
91f32b4fe5
commit
74155f7108
@ -1251,6 +1251,7 @@ angular.module('myApp.controllers', [])
|
|||||||
switch (update._) {
|
switch (update._) {
|
||||||
case 'updateUserTyping':
|
case 'updateUserTyping':
|
||||||
case 'updateChatUserTyping':
|
case 'updateChatUserTyping':
|
||||||
|
AppUsersManager.forceUserOnline(update.user_id);
|
||||||
if (AppUsersManager.hasUser(update.user_id) &&
|
if (AppUsersManager.hasUser(update.user_id) &&
|
||||||
$scope.curDialog.peerID == (update._ == 'updateUserTyping'
|
$scope.curDialog.peerID == (update._ == 'updateUserTyping'
|
||||||
? update.user_id
|
? update.user_id
|
||||||
|
@ -163,13 +163,21 @@ angular.module('myApp.services', [])
|
|||||||
var timestampNow = tsNow(true) + serverTimeOffset;
|
var timestampNow = tsNow(true) + serverTimeOffset;
|
||||||
angular.forEach(users, function (user) {
|
angular.forEach(users, function (user) {
|
||||||
if (user.status && user.status._ == 'userStatusOnline' &&
|
if (user.status && user.status._ == 'userStatusOnline' &&
|
||||||
user.status.expires > timestampNow) {
|
user.status.expires < timestampNow) {
|
||||||
user.status = {_: 'userStatusOffline', was_online: user.status.expires};
|
user.status = {_: 'userStatusOffline', was_online: user.status.expires};
|
||||||
$rootScope.$broadcast('user_update', user.id);
|
$rootScope.$broadcast('user_update', user.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function forceUserOnline (id) {
|
||||||
|
var user = getUser(id);
|
||||||
|
if (user && (!user.status || user.status._ != 'userStatusOnline')) {
|
||||||
|
user.status = {_: 'userStatusOnline', expires: tsNow(true) + serverTimeOffset + 60};
|
||||||
|
$rootScope.$broadcast('user_update', id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function wrapForFull (id) {
|
function wrapForFull (id) {
|
||||||
var user = getUser(id);
|
var user = getUser(id);
|
||||||
|
|
||||||
@ -311,6 +319,7 @@ angular.module('myApp.services', [])
|
|||||||
case 'updateUserPhoto':
|
case 'updateUserPhoto':
|
||||||
var userID = update.user_id;
|
var userID = update.user_id;
|
||||||
if (users[userID]) {
|
if (users[userID]) {
|
||||||
|
forceUserOnline(userID);
|
||||||
safeReplaceObject(users[userID].photo, update.photo);
|
safeReplaceObject(users[userID].photo, update.photo);
|
||||||
|
|
||||||
if (cachedPhotoLocations[userID] !== undefined) {
|
if (cachedPhotoLocations[userID] !== undefined) {
|
||||||
@ -336,6 +345,7 @@ angular.module('myApp.services', [])
|
|||||||
saveApiUser: saveApiUser,
|
saveApiUser: saveApiUser,
|
||||||
getUser: getUser,
|
getUser: getUser,
|
||||||
getUserInput: getUserInput,
|
getUserInput: getUserInput,
|
||||||
|
forceUserOnline: forceUserOnline,
|
||||||
getUserPhoto: getUserPhoto,
|
getUserPhoto: getUserPhoto,
|
||||||
getUserString: getUserString,
|
getUserString: getUserString,
|
||||||
getUserSearchText: getUserSearchText,
|
getUserSearchText: getUserSearchText,
|
||||||
@ -1998,6 +2008,10 @@ angular.module('myApp.services', [])
|
|||||||
peerID = getMessagePeer(message),
|
peerID = getMessagePeer(message),
|
||||||
historyStorage = historiesStorage[peerID];
|
historyStorage = historiesStorage[peerID];
|
||||||
|
|
||||||
|
if (!message.out) {
|
||||||
|
AppUsersManager.forceUserOnline(message.from_id);
|
||||||
|
}
|
||||||
|
|
||||||
if (historyStorage !== undefined) {
|
if (historyStorage !== undefined) {
|
||||||
var topMsgID = historiesStorage[peerID].history[0];
|
var topMsgID = historiesStorage[peerID].history[0];
|
||||||
if (historiesStorage[peerID].history.indexOf(message.id) != -1) {
|
if (historiesStorage[peerID].history.indexOf(message.id) != -1) {
|
||||||
@ -2058,9 +2072,8 @@ angular.module('myApp.services', [])
|
|||||||
$rootScope.$broadcast('dialogs_update', dialog);
|
$rootScope.$broadcast('dialogs_update', dialog);
|
||||||
|
|
||||||
|
|
||||||
if ((Config.Navigator.mobile && $rootScope.selectedPeerID != peerID || $rootScope.idle.isIDLE) &&
|
if (($rootScope.idle.isIDLE || Config.Mobile && $rootScope.selectedPeerID != peerID) &&
|
||||||
!message.out &&
|
!message.out && message.unread) {
|
||||||
message.unread) {
|
|
||||||
NotificationsManager.getPeerMuted(peerID).then(function (muted) {
|
NotificationsManager.getPeerMuted(peerID).then(function (muted) {
|
||||||
if (!message.unread || muted) {
|
if (!message.unread || muted) {
|
||||||
return;
|
return;
|
||||||
@ -2094,6 +2107,9 @@ angular.module('myApp.services', [])
|
|||||||
|
|
||||||
NotificationsManager.cancel('msg' + messageID);
|
NotificationsManager.cancel('msg' + messageID);
|
||||||
}
|
}
|
||||||
|
else if (peerID > 0) {
|
||||||
|
AppUsersManager.forceUserOnline(peerID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user