diff --git a/app/css/desktop.css b/app/css/desktop.css index ac190f4d..f6369fce 100644 --- a/app/css/desktop.css +++ b/app/css/desktop.css @@ -639,7 +639,8 @@ a.footer_link.active:active { color: #FFF; } .contacts_modal_members_list .active a.contacts_modal_contact .md_modal_list_peer_description, -.contacts_modal_members_list .active a.contacts_modal_contact:hover .md_modal_list_peer_description { +.contacts_modal_members_list .active a.contacts_modal_contact:hover .md_modal_list_peer_description, +.contacts_modal_members_list .active a.contacts_modal_contact .md_modal_list_peer_description .status_online { color: #FFF; } diff --git a/app/js/directives.js b/app/js/directives.js index 1d227353..3ec69b13 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -2090,10 +2090,17 @@ angular.module('myApp.directives', ['myApp.filters']) userID = $scope.$eval(attrs.myUserLink); update(); } + if (!attrs.noWatch) { + $scope.$on('user_update', function (e, updUserID) { + if (userID == updUserID) { + update(); + } + }); + } } }) - .directive('myUserStatus', function ($filter, $rootScope, AppUsersManager) { + .directive('myUserStatus', function ($filter, AppUsersManager) { var statusFilter = $filter('userStatus'), ind = 0, @@ -2125,7 +2132,7 @@ angular.module('myApp.directives', ['myApp.filters']) userID = newUserID; update(); }); - $rootScope.$on('user_update', function (e, updUserID) { + $scope.$on('user_update', function (e, updUserID) { if (userID == updUserID) { update(); } @@ -2137,6 +2144,46 @@ angular.module('myApp.directives', ['myApp.filters']) } }) + .directive('myChatLink', function ($timeout, AppChatsManager) { + + return { + link: link + }; + + function link($scope, element, attrs) { + var chatID; + var update = function () { + var chat = AppChatsManager.getChat(chatID); + + element.html( + (chat.rTitle || '').valueOf() + ) + }; + + if (element[0].tagName == 'A') { + element.on('click', function () { + AppChatsManager.openChat(chatID); + }); + } + + if (attrs.chatWatch) { + $scope.$watch(attrs.myChatLink, function (newChatID) { + chatID = newChatID; + update(); + }); + } else { + chatID = $scope.$eval(attrs.myChatLink); + update(); + } + + $scope.$on('chat_update', function (e, updChatID) { + if (chatID == updChatID) { + update(); + } + }); + } + }) + .directive('myChatStatus', function ($rootScope, _, MtpApiManager, AppChatsManager, AppUsersManager) { var ind = 0; diff --git a/app/js/services.js b/app/js/services.js index d92560f8..ea373ab9 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -243,6 +243,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) expires: tsNow(true) + serverTimeOffset + 60, wasStatus: wasStatus }; + user.sortStatus = getUserStatusForSort(user.status); $rootScope.$broadcast('user_update', id); } } @@ -364,6 +365,23 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) }); }; + function setUserStatus (userID, offline) { + var user = users[userID]; + if (user) { + var status = offline ? { + _: 'userStatusOffline', + was_online: tsNow(true) + serverTimeOffset + } : { + _: 'userStatusOnline', + expires: tsNow(true) + serverTimeOffset + 500 + }; + + user.status = status; + user.sortStatus = getUserStatusForSort(user.status); + $rootScope.$broadcast('user_update', userID); + } + } + $rootScope.$on('apiUpdate', function (e, update) { // console.log('on apiUpdate', update); @@ -373,7 +391,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) user = users[userID]; if (user) { user.status = update.status; - user.sortStatus = getUserStatusForSort(update.status); + user.sortStatus = getUserStatusForSort(user.status); $rootScope.$broadcast('user_update', userID); } break; @@ -407,6 +425,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) saveApiUser: saveApiUser, getUser: getUser, getUserInput: getUserInput, + setUserStatus: setUserStatus, forceUserOnline: forceUserOnline, getUserPhoto: getUserPhoto, getUserString: getUserString, @@ -3751,10 +3770,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) }) -.service('StatusManager', function ($timeout, $rootScope, MtpApiManager, IdleManager) { +.service('StatusManager', function ($timeout, $rootScope, MtpApiManager, AppUsersManager, IdleManager) { var toPromise; - var lastOnlineUpdated = 0 + var lastOnlineUpdated = 0; var started = false; var myID = 0; var myOtherDeviceActive = false; @@ -3790,6 +3809,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return; } lastOnlineUpdated = offline ? 0 : date; + AppUsersManager.setUserStatus(myID, offline); return MtpApiManager.invokeApi('account.updateStatus', { offline: offline }, {noErrorBox: true}); diff --git a/app/partials/desktop/chat_modal.html b/app/partials/desktop/chat_modal.html index 9e7274d3..93e4c41d 100644 --- a/app/partials/desktop/chat_modal.html +++ b/app/partials/desktop/chat_modal.html @@ -17,7 +17,7 @@