Restore index refresh notifications for users who want them.
This commit is contained in:
parent
778bbcba07
commit
a7d6d894dc
@ -10,6 +10,11 @@ Config =
|
||||
'Link to <%= meta.name %>\'s catalog instead of the native 4chan one.'
|
||||
1
|
||||
]
|
||||
'Index Refresh Notifications': [
|
||||
false
|
||||
'Show a notice at the top of the page when the index is refreshed.'
|
||||
1
|
||||
]
|
||||
'External Catalog': [
|
||||
false
|
||||
'Link to external catalog instead of the internal one.'
|
||||
|
||||
@ -414,13 +414,17 @@ Index =
|
||||
Index.req?.abort()
|
||||
Index.notice?.close()
|
||||
|
||||
# This notice only displays if Index Refresh is taking too long
|
||||
now = Date.now()
|
||||
$.ready ->
|
||||
Index.nTimeout = setTimeout (->
|
||||
if Index.req and !Index.notice
|
||||
Index.notice = new Notice 'info', 'Refreshing index...', 2
|
||||
), 3 * $.SECOND - (Date.now() - now)
|
||||
if Conf['Index Refresh Notifications'] and d.readyState isnt 'loading'
|
||||
# Optional notification for manual refreshes
|
||||
Index.notice = new Notice 'info', 'Refreshing index...'
|
||||
else
|
||||
# Also display notice if Index Refresh is taking too long
|
||||
now = Date.now()
|
||||
$.ready ->
|
||||
Index.nTimeout = setTimeout (->
|
||||
if Index.req and !Index.notice
|
||||
Index.notice = new Notice 'info', 'Refreshing index...'
|
||||
), 3 * $.SECOND - (Date.now() - now)
|
||||
|
||||
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD}/catalog.json",
|
||||
onloadend: (e) -> Index.load e, state
|
||||
@ -467,6 +471,14 @@ Index =
|
||||
new Notice 'error', 'Index refresh failed.', 1
|
||||
return
|
||||
|
||||
if notice
|
||||
if Conf['Index Refresh Notifications']
|
||||
notice.setType 'success'
|
||||
notice.el.lastElementChild.textContent = 'Index refreshed!'
|
||||
setTimeout notice.close, $.SECOND
|
||||
else
|
||||
notice.close()
|
||||
|
||||
timeEl = $ '#index-last-refresh time', Index.navLinks
|
||||
timeEl.dataset.utc = Date.parse req.getResponseHeader 'Last-Modified'
|
||||
RelativeDates.update timeEl
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user