Bug 488922 - Treat bookmarks restore specially

Add observers for bookmarks-restore-* and ignore changes during import and trigger a fresh start on success.
This commit is contained in:
Edward Lee 2009-12-02 19:20:44 -08:00
parent c52dbbee72
commit 4676b9cb18

View File

@ -48,6 +48,7 @@ const SERVICE_NOT_SUPPORTED = "Service not supported on this platform";
Cu.import("resource://gre/modules/utils.js");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://weave/ext/Observers.js");
Cu.import("resource://weave/util.js");
Cu.import("resource://weave/engines.js");
Cu.import("resource://weave/stores.js");
@ -91,6 +92,28 @@ BookmarksEngine.prototype = {
_storeObj: BookmarksStore,
_trackerObj: BookmarksTracker,
_init: function _init() {
SyncEngine.prototype._init.call(this);
this._handleImport();
},
_handleImport: function _handleImport() {
Observers.add("bookmarks-restore-begin", function() {
this._log.debug("Ignoring changes from importing bookmarks");
this._tracker.ignoreAll = true;
}, this);
Observers.add("bookmarks-restore-success", function() {
this._log.debug("Triggering fresh start on successful import");
this.resetLastSync();
this._tracker.ignoreAll = false;
}, this);
Observers.add("bookmarks-restore-failed", function() {
this._tracker.ignoreAll = false;
}, this);
},
_sync: Utils.batchSync("Bookmark", SyncEngine),
_syncStartup: function _syncStart() {