Convert settings imported from older versions.
This commit is contained in:
parent
fed0892179
commit
b02f263c47
@ -87,17 +87,10 @@ Main =
|
||||
|
||||
upgrade: (items) ->
|
||||
{previousversion} = items
|
||||
items2 = {previousversion: g.VERSION}
|
||||
compareString = previousversion.replace(/\d+/g, (x) -> ('0000'+x)[-5..])
|
||||
|
||||
if compareString < '00001.00011.00008.00000'
|
||||
unless items['Fixed Thread Watcher']?
|
||||
items2['Fixed Thread Watcher'] = items['Toggleable Thread Watcher'] ? true
|
||||
unless items['Exempt Archives from Encryption']?
|
||||
items2['Exempt Archives from Encryption'] = items['Except Archives from Encryption'] ? false
|
||||
|
||||
$.extend items, items2
|
||||
$.set items2, ->
|
||||
changes = {previousversion: g.VERSION}
|
||||
$.extend changes, Settings.upgrade(items, previousversion)
|
||||
$.extend items, changes
|
||||
$.set changes, ->
|
||||
if items['Show Updated Notifications'] ? true
|
||||
el = $.el 'span',
|
||||
<%= html(meta.name + ' has been updated to <a href="' + meta.changelog + '" target="_blank">version ${g.VERSION}</a>.') %>
|
||||
|
||||
@ -268,9 +268,21 @@ Settings =
|
||||
(data.Conf['watchedThreads'].boards[boardID] or= {})[threadID] = excerpt: threadData.textContent
|
||||
data
|
||||
|
||||
upgrade: (data, version) ->
|
||||
changes = {}
|
||||
compareString = version.replace(/\d+/g, (x) -> ('0000'+x)[-5..])
|
||||
if compareString < '00001.00011.00008.00000'
|
||||
unless data['Fixed Thread Watcher']?
|
||||
changes['Fixed Thread Watcher'] = data['Toggleable Thread Watcher'] ? true
|
||||
unless data['Exempt Archives from Encryption']?
|
||||
changes['Exempt Archives from Encryption'] = data['Except Archives from Encryption'] ? false
|
||||
changes
|
||||
|
||||
loadSettings: (data, cb) ->
|
||||
if data.version.split('.')[0] is '2' # https://github.com/loadletter/4chan-x
|
||||
data = Settings.convertFrom.loadletter data
|
||||
else if data.version isnt g.VERSION
|
||||
$.extend data.Conf, Settings.upgrade(data.Conf, data.version)
|
||||
$.clear (err) ->
|
||||
return cb err if err
|
||||
$.set data.Conf, cb
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user