issue 96 New styles have a URL of undefined

This commit is contained in:
Jason Barnabe 2013-06-23 23:16:48 -05:00
parent cfa80ee785
commit b7aa8b4b81
2 changed files with 14 additions and 6 deletions

View File

@ -198,12 +198,12 @@ function saveStyle(o, callback) {
}
} else {
// create a new record
if (!("updateUrl" in o)) {
o.updateUrl = null;
}
if (!("md5Url" in o)) {
o.md5Url = null;
}
// set optional things to null if they're undefined
["updateUrl", "md5Url", "url"].filter(function(att) {
return !(att in o);
}).forEach(function(att) {
o[att] = null;
});
t.executeSql('INSERT INTO styles (name, enabled, url, updateUrl, md5Url) VALUES (?, ?, ?, ?, ?);', [o.name, true, o.url, o.updateUrl, o.md5Url]);
}

View File

@ -11,6 +11,8 @@ function getDatabase(ready, error) {
dbV12(stylishDb, error, ready);
} else if (stylishDb.version == "1.2") {
dbV13(stylishDb, error, ready);
} else if (stylishDb.version == "1.3") {
dbV14(stylishDb, error, ready);
} else {
ready(stylishDb);
}
@ -51,6 +53,12 @@ function dbV13(d, error, done) {
}, error, function() { done(d)});
}
function dbV14(d, error, done) {
d.changeVersion(d.version, '1.4', function (t) {
t.executeSql('UPDATE styles SET url = null WHERE url = "undefined";');
}, error, function() { done(d)});
}
function enableStyle(id, enabled) {
getDatabase(function(db) {
db.transaction(function (t) {