Use UIDs instead of names to store selected archives.
This commit is contained in:
parent
d2bd583818
commit
36a0895ef6
@ -8,8 +8,8 @@ Redirect =
|
|||||||
|
|
||||||
archives = {}
|
archives = {}
|
||||||
for data in Redirect.archives
|
for data in Redirect.archives
|
||||||
{name, boards, files, software, withCredentials} = data
|
{uid, name, boards, files, software, withCredentials} = data
|
||||||
archives[name] = data
|
archives[JSON.stringify(uid ? name)] = data
|
||||||
for boardID in boards
|
for boardID in boards
|
||||||
unless withCredentials
|
unless withCredentials
|
||||||
o.thread[boardID] = data unless boardID of o.thread
|
o.thread[boardID] = data unless boardID of o.thread
|
||||||
@ -19,9 +19,9 @@ Redirect =
|
|||||||
|
|
||||||
for boardID, record of Conf['selectedArchives']
|
for boardID, record of Conf['selectedArchives']
|
||||||
for type, id of record
|
for type, id of record
|
||||||
if id is 'disabled'
|
if id is null
|
||||||
delete o[type][boardID]
|
delete o[type][boardID]
|
||||||
else if archive = archives[id]
|
else if archive = archives[JSON.stringify id]
|
||||||
boards = if type is 'file' then archive.files else archive.boards
|
boards = if type is 'file' then archive.files else archive.boards
|
||||||
o[type][boardID] = archive if boardID in boards
|
o[type][boardID] = archive if boardID in boards
|
||||||
|
|
||||||
|
|||||||
@ -281,6 +281,13 @@ Settings =
|
|||||||
changes['Fixed Thread Watcher'] = data['Toggleable Thread Watcher'] ? true
|
changes['Fixed Thread Watcher'] = data['Toggleable Thread Watcher'] ? true
|
||||||
unless data['Exempt Archives from Encryption']?
|
unless data['Exempt Archives from Encryption']?
|
||||||
changes['Exempt Archives from Encryption'] = data['Except Archives from Encryption'] ? false
|
changes['Exempt Archives from Encryption'] = data['Except Archives from Encryption'] ? false
|
||||||
|
if compareString < '00001.00011.00010.00001'
|
||||||
|
if data['selectedArchives']?
|
||||||
|
uids = {"Moe":0,"4plebs Archive":3,"Nyafuu Archive":4,"Love is Over":5,"Rebecca Black Tech":8,"warosu":10,"fgts":15,"not4plebs":22,"DesuStorage":23,"fireden.net":24,"disabled":null}
|
||||||
|
changes['selectedArchives'] = data['selectedArchives']
|
||||||
|
for boardID, record of changes['selectedArchives']
|
||||||
|
for type, name of record when name of uids
|
||||||
|
record[type] = uids[name]
|
||||||
changes
|
changes
|
||||||
|
|
||||||
loadSettings: (data, cb) ->
|
loadSettings: (data, cb) ->
|
||||||
@ -378,20 +385,21 @@ Settings =
|
|||||||
$.on applyCSS, 'click', Settings.usercss
|
$.on applyCSS, 'click', Settings.usercss
|
||||||
|
|
||||||
archBoards = {}
|
archBoards = {}
|
||||||
for {name, boards, files, software, withCredentials} in Redirect.archives
|
for {uid, name, boards, files, software, withCredentials} in Redirect.archives
|
||||||
for boardID in boards
|
for boardID in boards
|
||||||
o = archBoards[boardID] or=
|
o = archBoards[boardID] or=
|
||||||
thread: [[], []]
|
thread: [[], []]
|
||||||
post: [[], []]
|
post: [[], []]
|
||||||
file: [[], []]
|
file: [[], []]
|
||||||
i = +!!withCredentials
|
i = +!!withCredentials
|
||||||
o.thread[i].push name
|
archive = [uid ? name, name]
|
||||||
o.post[i].push name if software is 'foolfuuka'
|
o.thread[i].push archive
|
||||||
o.file[i].push name if boardID in files
|
o.post[i].push archive if software is 'foolfuuka'
|
||||||
|
o.file[i].push archive if boardID in files
|
||||||
for boardID, o of archBoards
|
for boardID, o of archBoards
|
||||||
for item in ['thread', 'post', 'file']
|
for item in ['thread', 'post', 'file']
|
||||||
i = if o[item][0].length then 1 else 0
|
i = if o[item][0].length then 1 else 0
|
||||||
o[item][i].push 'disabled'
|
o[item][i].push [null, 'disabled']
|
||||||
o[item] = o[item][0].concat(o[item][1])
|
o[item] = o[item][0].concat(o[item][1])
|
||||||
|
|
||||||
rows = []
|
rows = []
|
||||||
@ -424,9 +432,9 @@ Settings =
|
|||||||
|
|
||||||
$.get 'selectedArchives', Conf['selectedArchives'], ({selectedArchives}) ->
|
$.get 'selectedArchives', Conf['selectedArchives'], ({selectedArchives}) ->
|
||||||
for boardID, data of selectedArchives
|
for boardID, data of selectedArchives
|
||||||
for type, name of data
|
for type, id of data
|
||||||
if option = $ "select[data-boardid='#{boardID}'][data-type='#{type}'] > option[value='#{name}']", section
|
if select = $ "select[data-boardid='#{boardID}'][data-type='#{type}']", section
|
||||||
option.selected = true
|
select.value = JSON.stringify id
|
||||||
return
|
return
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -444,8 +452,8 @@ Settings =
|
|||||||
while i < length
|
while i < length
|
||||||
archive = data[type][i++]
|
archive = data[type][i++]
|
||||||
options.push $.el 'option',
|
options.push $.el 'option',
|
||||||
textContent: archive
|
value: JSON.stringify archive[0]
|
||||||
value: archive
|
textContent: archive[1]
|
||||||
|
|
||||||
$.extend td, <%= html('<select></select>') %>
|
$.extend td, <%= html('<select></select>') %>
|
||||||
select = td.firstElementChild
|
select = td.firstElementChild
|
||||||
@ -460,7 +468,7 @@ Settings =
|
|||||||
|
|
||||||
saveSelectedArchive: ->
|
saveSelectedArchive: ->
|
||||||
$.get 'selectedArchives', Conf['selectedArchives'], ({selectedArchives}) =>
|
$.get 'selectedArchives', Conf['selectedArchives'], ({selectedArchives}) =>
|
||||||
(selectedArchives[@dataset.boardid] or= {})[@dataset.type] = @value
|
(selectedArchives[@dataset.boardid] or= {})[@dataset.type] = JSON.parse @value
|
||||||
$.set 'selectedArchives', selectedArchives
|
$.set 'selectedArchives', selectedArchives
|
||||||
|
|
||||||
boardnav: ->
|
boardnav: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user