Re-select archives when the archives list gets updated
or when we select an archive in the settings.
This commit is contained in:
parent
f66bbee9f1
commit
5a10d5f75c
@ -1,31 +1,34 @@
|
|||||||
Redirect =
|
Redirect =
|
||||||
archives: `<%= JSON.stringify(grunt.file.readJSON('json/archives.json')) %>`
|
archives: `<%= JSON.stringify(grunt.file.readJSON('json/archives.json')) %>`
|
||||||
data:
|
|
||||||
thread: {}
|
|
||||||
post: {}
|
|
||||||
file: {}
|
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
|
@selectArchives()
|
||||||
|
@update()
|
||||||
|
|
||||||
|
selectArchives: ->
|
||||||
|
data =
|
||||||
|
thread: {}
|
||||||
|
post: {}
|
||||||
|
file: {}
|
||||||
for boardID, data of Conf['selectedArchives']
|
for boardID, data of Conf['selectedArchives']
|
||||||
for type, uid of data
|
for type, uid of data
|
||||||
for archive in Conf['archives']
|
for archive in Conf['archives']
|
||||||
continue if archive.uid isnt uid or type is 'post' and archive.software isnt 'foolfuuka'
|
continue if archive.uid isnt uid
|
||||||
|
break if type is 'post' and archive.software isnt 'foolfuuka'
|
||||||
arr = if type is 'file'
|
arr = if type is 'file'
|
||||||
archive.files
|
archive.files
|
||||||
else
|
else
|
||||||
archive.boards
|
archive.boards
|
||||||
Redirect.data[type][boardID] = archive if boardID in arr
|
data[type][boardID] = archive if boardID in arr
|
||||||
|
break
|
||||||
for archive in Conf['archives']
|
for archive in Conf['archives']
|
||||||
for boardID in archive.boards
|
for boardID in archive.boards
|
||||||
unless boardID of Redirect.data.thread
|
unless boardID of data.thread
|
||||||
Redirect.data.thread[boardID] = archive
|
data.thread[boardID] = archive
|
||||||
unless boardID of Redirect.data.post or archive.software isnt 'foolfuuka'
|
unless boardID of data.post or archive.software isnt 'foolfuuka'
|
||||||
Redirect.data.post[boardID] = archive
|
data.post[boardID] = archive
|
||||||
unless boardID of Redirect.data.file or boardID not in archive.files
|
unless boardID of data.file or boardID not in archive.files
|
||||||
Redirect.data.file[boardID] = archive
|
data.file[boardID] = archive
|
||||||
|
Redirect.data = data
|
||||||
Redirect.update()
|
|
||||||
|
|
||||||
update: (cb) ->
|
update: (cb) ->
|
||||||
$.get 'lastarchivecheck', 0, ({lastarchivecheck}) ->
|
$.get 'lastarchivecheck', 0, ({lastarchivecheck}) ->
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
@ -35,6 +38,7 @@ Redirect =
|
|||||||
$.ajax '<%= meta.page %>json/archives.json', onload: ->
|
$.ajax '<%= meta.page %>json/archives.json', onload: ->
|
||||||
if @status is 200
|
if @status is 200
|
||||||
Conf['archives'] = JSON.parse @response
|
Conf['archives'] = JSON.parse @response
|
||||||
|
Redirect.selectArchives()
|
||||||
$.set
|
$.set
|
||||||
lastarchivecheck: now
|
lastarchivecheck: now
|
||||||
archives: Conf['archives']
|
archives: Conf['archives']
|
||||||
|
|||||||
@ -435,6 +435,8 @@ 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] = +@value
|
||||||
|
Conf['selectedArchives'] = selectedArchives
|
||||||
|
Redirect.selectArchives()
|
||||||
$.set 'selectedArchives', selectedArchives
|
$.set 'selectedArchives', selectedArchives
|
||||||
|
|
||||||
keybinds: (section) ->
|
keybinds: (section) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user