Update archived boards list every 4 days.
This commit is contained in:
parent
5f3eae0f0c
commit
39c3d35a72
@ -1,6 +1,8 @@
|
||||
- **New feature**: `Archive selection`
|
||||
- Select which archive you want for specific boards and redirection type.
|
||||
- Access it in the `Archives` tab of the Settings window.
|
||||
- The list of archived boards will now update automatically, separately from 4chan X updates.
|
||||
- If you're an archiver and want [data](https://github.com/MayhemYDG/4chan-x/blob/v3/json/archives.json) about your archive to be updated, added or removed: send a PR or open an issue.
|
||||
- Fix quote previews getting 'stuck' in Opera.
|
||||
|
||||
### 3.3.1 - *2013-05-04*
|
||||
|
||||
@ -5,16 +5,18 @@ Redirect =
|
||||
file: {}
|
||||
|
||||
init: ->
|
||||
Redirect.update()
|
||||
|
||||
for boardID, data of Conf['selectedArchives']
|
||||
for type, uid of data
|
||||
for archive in Redirect.archives
|
||||
for archive in Conf['archives']
|
||||
continue if archive.uid isnt uid or type is 'post' and archive.software isnt 'foolfuuka'
|
||||
arr = if type is 'file'
|
||||
archive.files
|
||||
else
|
||||
archive.boards
|
||||
Redirect[type][boardID] = archive if boardID in arr
|
||||
for archive in Redirect.archives
|
||||
for archive in Conf['archives']
|
||||
for boardID in archive.boards
|
||||
unless boardID of Redirect.thread
|
||||
Redirect.thread[boardID] = archive
|
||||
@ -24,6 +26,23 @@ Redirect =
|
||||
Redirect.file[boardID] = archive
|
||||
return
|
||||
|
||||
update: ->
|
||||
items =
|
||||
lastarchivecheck: 0
|
||||
lastupdate: 0
|
||||
$.get items, (items) ->
|
||||
now = Date.now()
|
||||
# Update the list of archives every 4 days.
|
||||
# The list is also update when 4chan X gets updated.
|
||||
if items.lastupdate > now - 4 * $.DAY or items.lastarchivecheck > now - 4 * $.DAY
|
||||
return
|
||||
$.ajax '<%= meta.page %>json/archives.json', onload: ->
|
||||
return unless @status is 200
|
||||
Conf['archives'] = JSON.parse @response
|
||||
$.set
|
||||
lastarchivecheck: now
|
||||
archives: Conf['archives']
|
||||
|
||||
to: (dest, data) ->
|
||||
archive = (if dest is 'search' then Redirect.thread else Redirect[dest])[data.boardID]
|
||||
return '' unless archive
|
||||
|
||||
@ -15,6 +15,7 @@ Main =
|
||||
for db in DataBoards
|
||||
Conf[db] = boards: {}
|
||||
Conf['selectedArchives'] = {}
|
||||
Conf['archives'] = Redirect.archives
|
||||
$.get Conf, Main.initFeatures
|
||||
|
||||
$.on d, '4chanMainInit', Main.initStyle
|
||||
|
||||
@ -32,8 +32,13 @@ Settings =
|
||||
new Notification 'info', el, 30
|
||||
else
|
||||
$.on d, '4chanXInitFinished', Settings.open
|
||||
# The archive list will always be updated with 4chan X updates.
|
||||
Conf['archives'] = Redirect.archives
|
||||
now = Date.now()
|
||||
$.set
|
||||
lastupdate: Date.now()
|
||||
archives: Conf['archives']
|
||||
lastarchivecheck: now
|
||||
lastupdate: now
|
||||
previousversion: g.VERSION
|
||||
|
||||
Settings.addSection 'Main', Settings.main
|
||||
@ -393,7 +398,7 @@ Settings =
|
||||
"""
|
||||
|
||||
boards = {}
|
||||
for archive in Redirect.archives
|
||||
for archive in Conf['archives']
|
||||
for boardID in archive.boards
|
||||
data = boards[boardID] or= {
|
||||
thread: []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user