From aa6b1815630afe68199535c87cafe2346e2debbe Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Mon, 12 Jan 2015 22:57:12 -0700 Subject: [PATCH] Resolve a race condition? --- builds/appchan-x.user.js | 7 +++++++ builds/crx/script.js | 7 +++++++ src/General/Index.coffee | 3 +++ src/General/Navigate.coffee | 7 +++++++ 4 files changed, 24 insertions(+) diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 3fd10dc95..d47ba9969 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -18662,6 +18662,13 @@ return; } } + if (Navigate.isNavigating) { + return e != null ? e.preventDefault() : void 0; + } + Navigate.isNavigating = true; + setTimeout((function() { + return delete Navigate.isNavigating; + }), 100); if (this.pathname === Navigate.path) { if (g.VIEW === 'thread') { ThreadUpdater.update(); diff --git a/builds/crx/script.js b/builds/crx/script.js index d93fc9628..233d3cce8 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -18696,6 +18696,13 @@ return; } } + if (Navigate.isNavigating) { + return e != null ? e.preventDefault() : void 0; + } + Navigate.isNavigating = true; + setTimeout((function() { + return delete Navigate.isNavigating; + }), 100); if (this.pathname === Navigate.path) { if (g.VIEW === 'thread') { ThreadUpdater.update(); diff --git a/src/General/Index.coffee b/src/General/Index.coffee index e1aedfbfc..c5e1a3b28 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -101,12 +101,15 @@ Index = @selectMode = $ '#index-mode', @navLinks @selectSort = $ '#index-sort', @navLinks @selectSize = $ '#index-size', @navLinks + $.on @searchInput, 'input', @onSearchInput $.on $('#index-search-clear', @navLinks), 'click', @clearSearch $.on $('#hidden-toggle a', @navLinks), 'click', @cb.toggleHiddenThreads + for select in [@selectMode, @selectSort, @selectSize] select.value = Conf[select.name] $.on select, 'change', $.cb.value + $.on @selectMode, 'change', @cb.mode $.on @selectSort, 'change', @cb.sort $.on @selectSize, 'change', @cb.size diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 1be69ee90..88671a429 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -206,6 +206,13 @@ Navigate = Navigate.setMode @ unless e.button is 2 # Right Click return + return e?.preventDefault() if Navigate.isNavigating + + Navigate.isNavigating = true + + # XXX Prevent accidental double-navigates race condition + setTimeout (-> delete Navigate.isNavigating), 100 + if @pathname is Navigate.path if g.VIEW is 'thread' ThreadUpdater.update()