diff --git a/app/index.html b/app/index.html index b415a8c4..f07e7434 100644 --- a/app/index.html +++ b/app/index.html @@ -51,9 +51,9 @@ - + - + diff --git a/app/js/app.js b/app/js/app.js index 480af2a2..4579a37b 100644 --- a/app/js/app.js +++ b/app/js/app.js @@ -54,7 +54,7 @@ config(['$locationProvider', '$routeProvider', '$compileProvider', function($loc // $locationProvider.html5Mode(true); $routeProvider.when('/', {templateUrl: 'partials/welcome.html?2', controller: 'AppWelcomeController'}); - $routeProvider.when('/login', {templateUrl: 'partials/login.html?2', controller: 'AppLoginController'}); + $routeProvider.when('/login', {templateUrl: 'partials/login.html?3', controller: 'AppLoginController'}); $routeProvider.when('/im', {templateUrl: 'partials/im.html?6', controller: 'AppIMController', reloadOnSearch: false}); $routeProvider.otherwise({redirectTo: '/'}); diff --git a/app/js/controllers.js b/app/js/controllers.js index 6a93ba06..488961f7 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -21,22 +21,42 @@ angular.module('myApp.controllers', []) }); }) - .controller('AppLoginController', function ($scope, $location, MtpApiManager, ErrorService) { + .controller('AppLoginController', function ($scope, $location, $timeout, MtpApiManager, ErrorService) { var options = {dcID: 1}; $scope.credentials = {}; $scope.progress = {}; + $scope.callPending = {}; + + var callTimeout; function saveAuth (result) { MtpApiManager.setUserAuth(options.dcID, { expires: result.expires, id: result.user.id }); + $timeout.cancel(callTimeout); $location.url('/im'); }; + function callCheck () { + $timeout.cancel(callTimeout); + if (!(--$scope.callPending.remaining)) { + $scope.callPending.success = false; + MtpApiManager.invokeApi('auth.sendCall', { + phone_number: $scope.credentials.phone_number, + phone_code_hash: $scope.credentials.phone_code_hash + }).then(function () { + $scope.callPending.success = true; + }); + } else { + callTimeout = $timeout(callCheck, 1000); + } + } + $scope.sendCode = function () { + $timeout.cancel(callTimeout); $scope.progress.enabled = true; MtpApiManager.invokeApi('auth.checkPhone', { phone_number: $scope.credentials.phone_number @@ -60,6 +80,9 @@ angular.module('myApp.controllers', []) $scope.credentials.phone_occupied = sentCode.phone_registered; $scope.error = {}; + $scope.callPending.remaining = 10; + callCheck(); + }, function (error) { $scope.progress.enabled = false; console.log('sendCode error', error); diff --git a/app/partials/login.html b/app/partials/login.html index 573478ee..1aaa6ba5 100644 --- a/app/partials/login.html +++ b/app/partials/login.html @@ -20,6 +20,12 @@
We have sent you a code via SMS.
Please enter it below.
+ Telegram will call you in {{callPending.remaining | duration}} + Telegram is calling you + Telegram dialed your number +
+