Fix some bugs recently introduced
This commit is contained in:
parent
21b95ce1d3
commit
ac48d552fa
2 changed files with 22 additions and 17 deletions
|
@ -61,7 +61,7 @@ window.textsecure.api = function() {
|
|||
return new Promise(function(resolve, reject) {
|
||||
$.ajax(URL_BASE + URL_CALLS[param.call] + param.urlParameters, {
|
||||
type : param.httpType,
|
||||
data : param.jsonData && jsonThing(param.jsonData),
|
||||
data : param.jsonData && textsecure.utils.jsonThing(param.jsonData),
|
||||
contentType : 'application/json; charset=utf-8',
|
||||
dataType : 'json',
|
||||
|
||||
|
|
|
@ -194,6 +194,10 @@ window.textsecure.protos = function() {
|
|||
window.textsecure.utils = function() {
|
||||
var self = {};
|
||||
|
||||
|
||||
/****************************************
|
||||
*** Number conversion/checking stuff ***
|
||||
****************************************/
|
||||
function isNumeric(string) {
|
||||
return string.replace(/\D/g, '') === string;
|
||||
}
|
||||
|
@ -244,22 +248,14 @@ window.textsecure.utils = function() {
|
|||
return '+' + country_code + number;
|
||||
}
|
||||
|
||||
self.unencodeNumber(number) {
|
||||
return string.split(".")[0];
|
||||
self.unencodeNumber = function(number) {
|
||||
return number.split(".")[0];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/************************************************
|
||||
*** Utilities to store data in local storage ***
|
||||
************************************************/
|
||||
window.textsecure.storage = function() {
|
||||
var self = {};
|
||||
|
||||
/****************************
|
||||
*** Conversion Utilities ***
|
||||
****************************/
|
||||
/**************************
|
||||
*** JSON'ing Utilities ***
|
||||
**************************/
|
||||
function ensureStringed(thing) {
|
||||
if (getStringable(thing))
|
||||
return getString(thing);
|
||||
|
@ -278,10 +274,19 @@ window.textsecure.storage = function() {
|
|||
|
||||
}
|
||||
|
||||
function jsonThing(thing) {
|
||||
self.jsonThing = function(thing) {
|
||||
return JSON.stringify(ensureStringed(thing));
|
||||
}
|
||||
|
||||
return self;
|
||||
}();
|
||||
|
||||
/************************************************
|
||||
*** Utilities to store data in local storage ***
|
||||
************************************************/
|
||||
window.textsecure.storage = function() {
|
||||
var self = {};
|
||||
|
||||
/*****************************
|
||||
*** Base Storage Routines ***
|
||||
*****************************/
|
||||
|
@ -289,7 +294,7 @@ window.textsecure.storage = function() {
|
|||
//TODO
|
||||
if (value === undefined)
|
||||
throw new Error("Tried to store undefined");
|
||||
localStorage.setItem("e" + key, jsonThing(value));
|
||||
localStorage.setItem("e" + key, textsecure.utils.jsonThing(value));
|
||||
}
|
||||
|
||||
self.getEncrypted = function(key, defaultValue) {
|
||||
|
@ -307,7 +312,7 @@ window.textsecure.storage = function() {
|
|||
self.putUnencrypted = function(key, value) {
|
||||
if (value === undefined)
|
||||
throw new Error("Tried to store undefined");
|
||||
localStorage.setItem("u" + key, jsonThing(value));
|
||||
localStorage.setItem("u" + key, textsecure.utils.jsonThing(value));
|
||||
}
|
||||
|
||||
self.getUnencrypted = function(key, defaultValue) {
|
||||
|
|
Loading…
Reference in a new issue