Store theme globally, not per-repo

This commit is contained in:
Shadowfacts 2016-10-01 14:04:26 -04:00
parent abb31139ab
commit 31b5ec0b96
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 9 additions and 8 deletions

View File

@ -353,13 +353,14 @@ function goToPrevChunk() {
} }
function load() { function load() {
localforage.getItem("theme")
.then(loadTheme);
return localforage.getItem(repo) return localforage.getItem(repo)
.then((val) => { .then((val) => {
if (val && val[filePath] && val[filePath].hasOwnProperty("chunk") && val[filePath].chunks) { if (val && val[filePath] && val[filePath].hasOwnProperty("chunk") && val[filePath].chunks) {
let chunk = val[filePath].chunks[val[filePath].chunk]; let chunk = val[filePath].chunks[val[filePath].chunk];
loadInvalids(chunk); loadInvalids(chunk);
loadCursor(chunk); loadCursor(chunk);
loadTheme(val);
} else { } else {
save(); save();
} }
@ -367,6 +368,7 @@ function load() {
} }
function save() { function save() {
localforage.setItem("theme", saveTheme());
localforage.getItem(repo) localforage.getItem(repo)
.then((val) => { .then((val) => {
if (!val) val = {}; if (!val) val = {};
@ -380,7 +382,6 @@ function save() {
let chunk = file.chunks[file.chunk]; let chunk = file.chunks[file.chunk];
saveInvalids(chunk); saveInvalids(chunk);
saveCursor(chunk); saveCursor(chunk);
saveTheme(val);
localforage.setItem(repo, val) localforage.setItem(repo, val)
.catch((e) => { .catch((e) => {
@ -419,15 +420,15 @@ function saveInvalids(obj) {
obj.invalids = serialized; obj.invalids = serialized;
} }
function loadTheme(obj) { function loadTheme(theme) {
if (obj && obj.theme) { if (theme) {
themeSelector.val(obj.theme); themeSelector.val(theme);
setTheme(obj.theme); setTheme(theme);
} }
} }
function saveTheme(obj) { function saveTheme() {
obj.theme = themeSelector.val(); return themeSelector.val();
} }
function loadCursor(obj) { function loadCursor(obj) {