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