aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2014-04-19 11:00:32 +0100
committerStephen Blott2014-04-19 11:00:32 +0100
commit222d53fe43e34d8d2fd7c2fd859de53cf5fee1f3 (patch)
tree7164c182d234b2a6006d238294dceb530c1af6af
parent5ea93cd18611d859867bdd80c44c886d29a7b958 (diff)
downloadvimium-222d53fe43e34d8d2fd7c2fd859de53cf5fee1f3.tar.bz2
Delay initializing sync until other components have started.
-rw-r--r--background_scripts/main.coffee3
-rw-r--r--background_scripts/sync.coffee6
-rw-r--r--tests/unit_tests/settings_test.coffee1
-rw-r--r--tests/unit_tests/utils_test.coffee1
4 files changed, 9 insertions, 2 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index f564f477..dc853803 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -596,3 +596,6 @@ chrome.windows.getAll { populate: true }, (windows) ->
createScrollPositionHandler = ->
(response) -> updateScrollPosition(tab, response.scrollX, response.scrollY) if response?
chrome.tabs.sendMessage(tab.id, { name: "getScrollPosition" }, createScrollPositionHandler())
+
+# Start pulling changes from synchrized storage.
+Sync.init()
diff --git a/background_scripts/sync.coffee b/background_scripts/sync.coffee
index 3b34c5a6..b1ccb696 100644
--- a/background_scripts/sync.coffee
+++ b/background_scripts/sync.coffee
@@ -25,9 +25,11 @@ root.Sync = Sync =
storage: chrome.storage.sync
doNotSync: [ "settingsVersion", "previousVersion" ]
+ register: ->
+ chrome.storage.onChanged.addListener (changes, area) -> Sync.listener changes, area
+
init: ->
chrome.storage.onChanged.addListener (changes, area) -> Sync.listener changes, area
- @pull()
# Asynchronous fetch from synced storage, called only at startup.
pull: ->
@@ -126,5 +128,5 @@ root.Sync = Sync =
return false
return true
-Sync.init()
+Sync.register()
diff --git a/tests/unit_tests/settings_test.coffee b/tests/unit_tests/settings_test.coffee
index 9aec95dd..4b6f3498 100644
--- a/tests/unit_tests/settings_test.coffee
+++ b/tests/unit_tests/settings_test.coffee
@@ -6,6 +6,7 @@ Utils.getCurrentVersion = -> '1.44'
global.localStorage = {}
extend(global,require "../../background_scripts/sync.js")
extend(global,require "../../background_scripts/settings.js")
+Sync.init()
context "settings",
diff --git a/tests/unit_tests/utils_test.coffee b/tests/unit_tests/utils_test.coffee
index 09e15353..356bc39f 100644
--- a/tests/unit_tests/utils_test.coffee
+++ b/tests/unit_tests/utils_test.coffee
@@ -3,6 +3,7 @@ require "./test_chrome_stubs.js"
extend(global, require "../../lib/utils.js")
extend(global, require "../../background_scripts/sync.js")
extend(global, require "../../background_scripts/settings.js")
+Sync.init()
context "isUrl",
should "accept valid URLs", ->