From 2f9e7a06d74c247af5a726c6fc2c24dfe6d34d52 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Wed, 21 Aug 2013 03:14:38 -0700 Subject: [PATCH] Fix mascot and theme saving --- LICENSE | 2 +- builds/appchan-x.user.js | 16 +++++++++++----- builds/crx/script.js | 16 +++++++++++----- src/General/Main.coffee | 7 +++++-- src/Theming/Mascots.coffee | 3 +-- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/LICENSE b/LICENSE index dbee0bbf7..074a61ffc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* appchan x - Version 2.3.5 - 2013-08-20 +* appchan x - Version 2.3.5 - 2013-08-21 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 7ebb2b7e5..d61684fb3 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -20,7 +20,7 @@ // ==/UserScript== /* -* appchan x - Version 2.3.5 - 2013-08-20 +* appchan x - Version 2.3.5 - 2013-08-21 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -12136,10 +12136,10 @@ } } Mascots[name] = imported; - $.get("userMascots", {}, function(item) { + $.get("userMascots", {}, function(_arg) { var userMascots; - userMascots = item['userMascots']; + userMascots = _arg.userMascots; userMascots[name] = Mascots[name]; return $.set('userMascots', userMascots); }); @@ -15374,17 +15374,23 @@ }; } $.extend(Conf, { - 'userThemes': [], - 'userMascots': [], 'Enabled Mascots': [], 'Enabled Mascots sfw': [], 'Enabled Mascots nsfw': [], 'Deleted Mascots': [], 'Hidden Categories': ["Questionable"], + 'userThemes': {}, + 'userMascots': {}, 'selectedArchives': {}, 'CachedTitles': {} }); return $.get(Conf, function(items) { + if (items.userMascots instanceof Array) { + $.set('userMascots', items.userMascots = {}); + } + if (items.userThemes instanceof Array) { + $.set('userThemes', items.userThemes = {}); + } $.extend(Conf, items); return Main.initFeatures(); }); diff --git a/builds/crx/script.js b/builds/crx/script.js index cf2c4ae6a..68f587f09 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* appchan x - Version 2.3.5 - 2013-08-20 +* appchan x - Version 2.3.5 - 2013-08-21 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -12129,10 +12129,10 @@ } } Mascots[name] = imported; - $.get("userMascots", {}, function(item) { + $.get("userMascots", {}, function(_arg) { var userMascots; - userMascots = item['userMascots']; + userMascots = _arg.userMascots; userMascots[name] = Mascots[name]; return $.set('userMascots', userMascots); }); @@ -15359,17 +15359,23 @@ }; } $.extend(Conf, { - 'userThemes': [], - 'userMascots': [], 'Enabled Mascots': [], 'Enabled Mascots sfw': [], 'Enabled Mascots nsfw': [], 'Deleted Mascots': [], 'Hidden Categories': ["Questionable"], + 'userThemes': {}, + 'userMascots': {}, 'selectedArchives': {}, 'CachedTitles': {} }); return $.get(Conf, function(items) { + if (items.userMascots instanceof Array) { + $.set('userMascots', items.userMascots = {}); + } + if (items.userThemes instanceof Array) { + $.set('userThemes', items.userThemes = {}); + } $.extend(Conf, items); if (!items) { new Notice('error', $.el('span', { diff --git a/src/General/Main.coffee b/src/General/Main.coffee index af1383eb0..0eedc404a 100644 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -18,17 +18,20 @@ Main = Conf[db] = boards: {} $.extend Conf, - 'userThemes': [] - 'userMascots': [] 'Enabled Mascots': [] 'Enabled Mascots sfw': [] 'Enabled Mascots nsfw': [] 'Deleted Mascots': [] 'Hidden Categories': ["Questionable"] + 'userThemes': {} + 'userMascots': {} 'selectedArchives': {} 'CachedTitles': {} $.get Conf, (items) -> + # TempFix for accidental declaration as an array. Remove by 2.4.? + $.set 'userMascots', items.userMascots = {} if items.userMascots instanceof Array + $.set 'userThemes', items.userThemes = {} if items.userThemes instanceof Array $.extend Conf, items <% if (type === 'crx') { %> unless items diff --git a/src/Theming/Mascots.coffee b/src/Theming/Mascots.coffee index 188bf6a80..33252cffb 100644 --- a/src/Theming/Mascots.coffee +++ b/src/Theming/Mascots.coffee @@ -315,8 +315,7 @@ MascotTools = Mascots[name] = imported - $.get "userMascots", {}, (item) -> - userMascots = item['userMascots'] + $.get "userMascots", {}, ({userMascots}) -> userMascots[name] = Mascots[name] $.set 'userMascots', userMascots