diff --git a/app/js/controllers.js b/app/js/controllers.js index 01a94e17..5991443b 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -55,7 +55,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.credentials = {phone_country: '', phone_country_name: '', phone_number: '', phone_full: ''}; $scope.progress = {}; - $scope.callPending = {}; + $scope.nextPending = {}; $scope.about = {}; $scope.chooseCountry = function () { @@ -158,38 +158,20 @@ angular.module('myApp.controllers', ['myApp.i18n']) initPhoneCountry(); - var callTimeout; + var nextTimeout; var updatePasswordTimeout = false; function saveAuth (result) { MtpApiManager.setUserAuth(options.dcID, { id: result.user.id }); - $timeout.cancel(callTimeout); + $timeout.cancel(nextTimeout); $location.url('/im'); }; - function callCheck () { - $timeout.cancel(callTimeout); - if ($scope.credentials.viaApp) { - return; - } - if (!(--$scope.callPending.remaining)) { - $scope.callPending.success = false; - MtpApiManager.invokeApi('auth.sendCall', { - phone_number: $scope.credentials.phone_full, - phone_code_hash: $scope.credentials.phone_code_hash - }, options).then(function () { - $scope.callPending.success = true; - }); - } else { - callTimeout = $timeout(callCheck, 1000); - } - } - $scope.sendCode = function () { - $timeout.cancel(callTimeout); + $timeout.cancel(nextTimeout); ErrorService.confirm({ type: 'LOGIN_PHONE_CORRECT', @@ -204,26 +186,18 @@ angular.module('myApp.controllers', ['myApp.i18n']) var authKeyStarted = tsNow(); MtpApiManager.invokeApi('auth.sendCode', { + flags: 0, phone_number: $scope.credentials.phone_full, - sms_type: 5, api_id: Config.App.id, api_hash: Config.App.hash, lang_code: navigator.language || 'en' }, options).then(function (sentCode) { $scope.progress.enabled = false; - $scope.credentials.phone_code_hash = sentCode.phone_code_hash; - $scope.credentials.phone_occupied = sentCode.phone_registered; - $scope.credentials.viaApp = sentCode._ == 'auth.sentAppCode'; - $scope.callPending.remaining = sentCode.send_call_timeout || 60; $scope.error = {}; $scope.about = {}; - - callCheck(); - - onContentLoaded(function () { - $scope.$broadcast('ui_height'); - }); + $scope.credentials.phone_code_hash = sentCode.phone_code_hash; + applySentCode(sentCode); }, function (error) { $scope.progress.enabled = false; @@ -246,28 +220,71 @@ angular.module('myApp.controllers', ['myApp.i18n']) }); } - $scope.sendSms = function () { - if (!$scope.credentials.viaApp) { + function applySentCode(sentCode) { + $scope.credentials.type = sentCode.type; + $scope.nextPending.type = sentCode.next_type || false; + $scope.nextPending.remaining = sentCode.timeout || false; + + nextTimeoutCheck(); + + onContentLoaded(function () { + $scope.$broadcast('ui_height'); + }); + } + + $scope.sendNext = function () { + if (!$scope.nextPending.type || + $scope.nextPending.remaining > 0) { return; } - delete $scope.credentials.viaApp; - MtpApiManager.invokeApi('auth.sendSms', { + MtpApiManager.invokeApi('auth.resendCode', { phone_number: $scope.credentials.phone_full, phone_code_hash: $scope.credentials.phone_code_hash - }, options).then(callCheck); + }, options).then(applySentCode); + } + + function nextTimeoutCheck () { + $timeout.cancel(nextTimeout); + if (!$scope.nextPending.type || + $scope.nextPending.remaining === false) { + return; + } + if (!(--$scope.nextPending.remaining)) { + $scope.nextPending.success = false; + $scope.sendNext(); + } else { + nextTimeout = $timeout(nextTimeoutCheck, 1000); + } } $scope.editPhone = function () { - $timeout.cancel(callTimeout); + $timeout.cancel(nextTimeout); + + if ($scope.credentials.phone_full && + $scope.credentials.phone_code_hash) { + MtpApiManager.invokeApi('auth.cancelCode', { + phone_number: $scope.credentials.phone_full, + phone_code_hash: $scope.credentials.phone_code_hash + }, options); + } delete $scope.credentials.phone_code_hash; delete $scope.credentials.phone_unoccupied; delete $scope.credentials.phone_code_valid; - delete $scope.credentials.viaApp; - delete $scope.callPending.remaining; - delete $scope.callPending.success; + delete $scope.nextPending.remaining; + delete $scope.nextPending.success; } + $scope.$watch('credentials.phone_code', function (newVal) { + if (newVal && + newVal.match(/^\d+$/) && + $scope.credentials.type && + $scope.credentials.type.length && + newVal.length == $scope.credentials.type.length) { + $scope.logIn(); + } + }); + $scope.logIn = function (forceSignUp) { var method = 'auth.signIn', params = { phone_number: $scope.credentials.phone_full, @@ -3080,9 +3097,9 @@ angular.module('myApp.controllers', ['myApp.i18n']) }) - .controller('VideoModalController', function ($scope, $rootScope, $modalInstance, PeersSelectService, AppMessagesManager, AppVideoManager, AppPeersManager, ErrorService) { + .controller('VideoModalController', function ($scope, $rootScope, $modalInstance, PeersSelectService, AppMessagesManager, AppDocsManager, AppPeersManager, ErrorService) { - $scope.video = AppVideoManager.wrapForFull($scope.videoID); + $scope.video = AppDocsManager.wrapVideoForFull($scope.docID); $scope.progress = {enabled: false}; $scope.player = {}; @@ -3109,7 +3126,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) }; $scope.download = function () { - AppVideoManager.saveVideoFile($scope.videoID); + AppDocsManager.saveDocFile($scope.docID); }; $scope.$on('history_delete', function (e, historyUpdate) { diff --git a/app/js/directives.js b/app/js/directives.js index 6a7d0e93..206b8e40 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -579,24 +579,6 @@ angular.module('myApp.directives', ['myApp.filters']) } }; }) - .directive('myMessageVideo', function(AppDocsManager) { - return { - scope: { - 'media': '=myMessageVideo', - 'messageId': '=messageId' - }, - templateUrl: templateUrl('message_attach_video'), - link: function ($scope, element, attrs) { - AppDocsManager.updateDocDownloaded($scope.media.video.id); - $scope.videoSave = function () { - AppDocsManager.saveDocFile($scope.media.video.id); - }; - $scope.videoOpen = function () { - AppDocsManager.openVideo($scope.media.video.id, $scope.messageId); - }; - } - }; - }) .directive('myMessageDocument', function(AppDocsManager) { return { scope: { @@ -615,6 +597,9 @@ angular.module('myApp.directives', ['myApp.filters']) } AppDocsManager.openDoc($scope.media.document.id, $scope.messageId); }; + $scope.videoOpen = function () { + AppDocsManager.openVideo($scope.media.document.id, $scope.messageId); + }; } }; }) diff --git a/app/js/messages_manager.js b/app/js/messages_manager.js index afe3554b..505b9f31 100644 --- a/app/js/messages_manager.js +++ b/app/js/messages_manager.js @@ -260,7 +260,9 @@ angular.module('myApp.services') dialog.top_message > maxSeenID ) { var notifyPeer = message.flags & 16 ? message.from_id : peerID; - if (message.pFlags.unread && !message.pFlags.out) { + if (message.pFlags.unread && + !message.pFlags.out && + !message.pFlags.silent) { NotificationsManager.getPeerMuted(notifyPeer).then(function (muted) { if (!muted) { notifyAboutMessage(message); @@ -1188,14 +1190,16 @@ angular.module('myApp.services') } apiMessage.date -= serverTimeOffset; - if (apiMessage.fwd_date) { - apiMessage.fwd_date -= serverTimeOffset; + + var fwdHeader = apiMessage.fwd_from; + if (fwdHeader) { + apiMessage.fwdFromID = fwdHeader.from_id ? fwdHeader.from_id : -fwdHeader.channel_id; + fwdHeader.date -= serverTimeOffset; } + apiMessage.toID = toPeerID; apiMessage.fromID = apiMessage.from_id || toPeerID; - if (apiMessage.fwd_from_id) { - apiMessage.fwdFromID = AppPeersManager.getPeerID(apiMessage.fwd_from_id); - } + if (apiMessage.via_bot_id > 0) { apiMessage.viaBotID = apiMessage.via_bot_id; } @@ -2387,10 +2391,6 @@ angular.module('myApp.services') sticker = true; } break; - - case 'messageMediaVideo': - thumbPhotoSize = message.media.video.thumb; - break; } } @@ -2746,7 +2746,9 @@ angular.module('myApp.services') newDialogsHandlePromise = $timeout(handleNewDialogs, 0); } - if (inboxUnread && ($rootScope.selectedPeerID != peerID || $rootScope.idle.isIDLE)) { + if (inboxUnread && + ($rootScope.selectedPeerID != peerID || $rootScope.idle.isIDLE) && + !message.pFlags.silent) { var notifyPeer = message.flags & 16 ? message.from_id : peerID; var notifyPeerToHandle = notificationsToHandle[notifyPeer]; diff --git a/app/js/services.js b/app/js/services.js index 44aa832d..f84c7877 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -94,6 +94,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) } var userID = apiUser.id; + var result = users[userID]; + + if (apiUser.pFlags === undefined) { + apiUser.pFlags = {}; + } + + if (apiUser.pFlags.min) { + if (result !== undefined) { + return; + } + } if (apiUser.phone) { apiUser.rPhone = $filter('phoneNumber')(apiUser.phone); @@ -114,10 +125,6 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) usernames[searchUsername] = userID; } - if (apiUser.pFlags === undefined) { - apiUser.pFlags = {}; - } - apiUser.sortName = apiUser.pFlags.deleted ? '' : SearchIndexManager.cleanSearchText(apiUser.first_name + ' ' + (apiUser.last_name || '')); var nameWords = apiUser.sortName.split(' '); @@ -191,8 +198,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return users[id] && users[id].pFlags.bot; } - function hasUser(id) { - return angular.isObject(users[id]); + function hasUser(id, allowMin) { + var user = users[id]; + return angular.isObject(user) && (!allowMin || !user.pFlags.min); } function getUserPhoto(id) { @@ -592,6 +600,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) } apiChat.rTitle = RichTextProcessor.wrapRichText(apiChat.title, {noLinks: true, noLinebreaks: true}) || _('chat_title_deleted'); + var result = chats[apiChat.id]; var titleWords = SearchIndexManager.cleanSearchText(apiChat.title || '').split(' '); var firstWord = titleWords.shift(); var lastWord = titleWords.pop(); @@ -602,16 +611,21 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) if (apiChat.pFlags === undefined) { apiChat.pFlags = {}; } + if (apiChat.pFlags.min) { + if (result !== undefined) { + return; + } + } if (apiChat.username) { var searchUsername = SearchIndexManager.cleanUsername(apiChat.username); usernames[searchUsername] = apiChat.id; } - if (chats[apiChat.id] === undefined) { - chats[apiChat.id] = apiChat; + if (result === undefined) { + result = chats[apiChat.id] = apiChat; } else { - safeReplaceObject(chats[apiChat.id], apiChat); + safeReplaceObject(result, apiChat); $rootScope.$broadcast('chat_update', apiChat.id); } @@ -653,7 +667,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) case 'invite': if (chat._ == 'channel') { if (chat.pFlags.megagroup) { - if (!chat.pFlags.editor) { + if (!chat.pFlags.editor && + !(action == 'invite' && chat.pFlags.democracy)) { return false; } } else { @@ -717,8 +732,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) } } - function hasChat (id) { - return angular.isObject(chats[id]); + function hasChat (id, allowMin) { + var chat = chats[id]; + return angular.isObject(chat) && (!allowMin || !chat.pFlags.min); } function getChatPhoto(id) { @@ -1778,7 +1794,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) apiDoc.duration = attribute.duration; apiDoc.w = attribute.w; apiDoc.h = attribute.h; - apiDoc.type = 'video'; + if (apiDoc.thumb) { + apiDoc.type = 'video'; + } break; case 'documentAttributeSticker': apiDoc.sticker = true; @@ -1794,7 +1812,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) apiDoc.stickerSetInput = attribute.stickerset; } } - if (apiDoc.mime_type == 'image/webp') { + if (apiDoc.thumb && apiDoc.mime_type == 'image/webp') { apiDoc.type = 'sticker'; } break; @@ -1804,8 +1822,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) break; case 'documentAttributeAnimated': if ((apiDoc.mime_type == 'image/gif' || apiDoc.mime_type == 'video/mp4') && - apiDoc.thumb && - apiDoc.thumb._ == 'photoSize') { + apiDoc.thumb) { apiDoc.type = 'gif'; } apiDoc.animated = true; @@ -1846,7 +1863,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) if (doc.file_name) { return doc.file_name; } - var fileExt = '.' + doc.mime_type.split('.')[1]; + var fileExt = '.' + doc.mime_type.split('/')[1]; if (fileExt == '.octet-stream') { fileExt = ''; } @@ -2005,7 +2022,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) function saveDocFile (docID) { var doc = docs[docID], historyDoc = docsForHistory[docID] || doc || {}, - mimeType = video.mime_type || 'video/mp4', + mimeType = doc.mime_type, fileName = getFileName(doc), ext = (fileName.split('.', 2) || [])[1] || ''; @@ -2728,8 +2745,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) to_id: AppPeersManager.getOutputPeer(toID), date: updateMessage.date, message: updateMessage.message, - fwd_from_id: updateMessage.fwd_from_id, - fwd_date: updateMessage.fwd_date, + fwd_from: updateMessage.fwd_from, reply_to_msg_id: updateMessage.reply_to_msg_id, entities: updateMessage.entities }, @@ -2932,13 +2948,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return false; } - if (update._ == 'updateNewMessage') { + if (update._ == 'updateNewMessage' || + update._ == 'updateNewChannelMessage') { var message = update.message; - var fwdPeerID = message.fwd_from_id ? AppPeersManager.getPeerID(message.fwd_from_id) : 0; var toPeerID = AppPeersManager.getPeerID(message.to_id); - if (message.from_id && !AppUsersManager.hasUser(message.from_id) || - fwdPeerID > 0 && !AppUsersManager.hasUser(fwdPeerID) || - fwdPeerID < 0 && !AppChatsManager.hasChat(-fwdPeerID) || + var fwdHeader = message.fwdHeader || {}; + if (message.from_id && !AppUsersManager.hasUser(message.from_id, message.pFlags.post) || + fwdHeader.from_id && !AppUsersManager.hasUser(fwdHeader.from_id, !!fwdHeader.channel_id) || + fwdHeader.channel_id && !AppChatsManager.hasChat(fwdHeader.channel_id) || toPeerID > 0 && !AppUsersManager.hasUser(toPeerID) || toPeerID < 0 && !AppChatsManager.hasChat(-toPeerID)) { console.warn(dT(), 'Short update not enough data', message); diff --git a/app/less/app.less b/app/less/app.less index 33d7b96d..4a9443dc 100644 --- a/app/less/app.less +++ b/app/less/app.less @@ -2348,7 +2348,7 @@ a.im_message_fwd_photo { } } .im_history_loading { - width: 60px; + width: 35px; margin: 0 auto; visibility: hidden; diff --git a/app/partials/desktop/forwarded_messages.html b/app/partials/desktop/forwarded_messages.html index 486ea46b..8f48af1d 100644 --- a/app/partials/desktop/forwarded_messages.html +++ b/app/partials/desktop/forwarded_messages.html @@ -15,16 +15,17 @@
- - - - + + - () + + + + + - diff --git a/app/partials/desktop/im.html b/app/partials/desktop/im.html index 19032d60..80d195a0 100644 --- a/app/partials/desktop/im.html +++ b/app/partials/desktop/im.html @@ -106,7 +106,7 @@
-
+
diff --git a/app/partials/desktop/login.html b/app/partials/desktop/login.html index 50c7f9a8..3917b6d1 100644 --- a/app/partials/desktop/login.html +++ b/app/partials/desktop/login.html @@ -56,26 +56,32 @@
-
-
- - -
-
- - - -
+ +
+ + +
+ +
+ +
+
+ +
+ + +
diff --git a/app/partials/desktop/message.html b/app/partials/desktop/message.html index 74113f94..077b264d 100644 --- a/app/partials/desktop/message.html +++ b/app/partials/desktop/message.html @@ -55,7 +55,7 @@
-   [ +   [ @@ -67,18 +67,14 @@
-
-
-
- The message is not supported on your version of Telegram Web. Update the app to view: web.telegram.org. -
+
The message is not supported on your version of Telegram Web. Update the app to view: web.telegram.org.
diff --git a/app/partials/desktop/message_attach_document.html b/app/partials/desktop/message_attach_document.html index 9edaa798..cd77e898 100644 --- a/app/partials/desktop/message_attach_document.html +++ b/app/partials/desktop/message_attach_document.html @@ -12,6 +12,41 @@
+
+ + + + + + +
+
+ [ ] + + +
+
+ + + + + +
+
+ +
+
+
+
+
+
+
+
+
diff --git a/app/partials/desktop/message_attach_video.html b/app/partials/desktop/message_attach_video.html deleted file mode 100644 index 2b9aef45..00000000 --- a/app/partials/desktop/message_attach_video.html +++ /dev/null @@ -1,35 +0,0 @@ -
- - - - - - -
-
- [ ] - - -
-
- - - - - -
-
- -
-
-
-
-
-
-
-
-
\ No newline at end of file diff --git a/app/partials/mobile/login.html b/app/partials/mobile/login.html index d57909cd..c5cae8fd 100644 --- a/app/partials/mobile/login.html +++ b/app/partials/mobile/login.html @@ -66,24 +66,28 @@ -
-
- - -
-
- - - -
+ +
+ + +
+ +
+ + +
+ +
+
diff --git a/app/partials/mobile/message.html b/app/partials/mobile/message.html index 1a162f36..da61fa43 100644 --- a/app/partials/mobile/message.html +++ b/app/partials/mobile/message.html @@ -59,9 +59,7 @@
-
-
diff --git a/app/partials/mobile/message_attach_document.html b/app/partials/mobile/message_attach_document.html index 5c309abd..dd117092 100644 --- a/app/partials/mobile/message_attach_document.html +++ b/app/partials/mobile/message_attach_document.html @@ -12,6 +12,18 @@
+ +