diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 6915c647b..322bcc5f9 100755 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -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.' diff --git a/src/General/Index.coffee b/src/General/Index.coffee index a281d02e1..7ffd1ed4c 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -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