From 56433bd9afba2a539c047405083018e1611e53f9 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 27 May 2014 21:35:37 +0200 Subject: [PATCH] One more tiny error refactor --- js/api.js | 8 +------- js/options.js | 13 +++++++------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/js/api.js b/js/api.js index 629a2523f..0c107e588 100644 --- a/js/api.js +++ b/js/api.js @@ -111,17 +111,11 @@ window.textsecure.api = function() { }); }; - self.requestVerificationCode = function(number, success_callback, error_callback) { + self.requestVerificationCode = function(number) { doAjax({ call : 'accounts', httpType : 'GET', urlParameters : '/sms/code/' + number, - }).then(function(response) { - if (success_callback !== undefined) - success_callback(response); - }).catch(function(code) { - if (error_callback !== undefined) - error_callback(code); }); }; diff --git a/js/options.js b/js/options.js index 562b413de..6b79cba18 100644 --- a/js/options.js +++ b/js/options.js @@ -59,12 +59,13 @@ $('#init-go-single-client').click(function() { single_device = true; - textsecure.api.requestVerificationCode(number, - function(response) { }, - function(code) { - alert("Failed to send key?" + code); //TODO - } - ); + textsecure.api.requestVerificationCode(number).catch(function(error) { + //TODO: No alerts + if (error.humanReadable) + alert(error.humanReadable); + else + alert(error); // XXX + }); }); $('#init-go').click(function() {