From 8266262c8a8318b194ba076741f5e80d804d78b8 Mon Sep 17 00:00:00 2001 From: Xelio Date: Wed, 8 May 2013 21:56:51 +0800 Subject: [PATCH] Plugin Sync: update callback will fire if full updated is performed --- plugins/sync.user.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/sync.user.js b/plugins/sync.user.js index 91b106da..7dad80ec 100644 --- a/plugins/sync.user.js +++ b/plugins/sync.user.js @@ -47,9 +47,12 @@ window.plugin.sync.updateMap = function(pluginName, fieldName, keyArray) { // example: plugin.sync.registerMapForSync('keys', 'keysdata', plugin.keys.updateCallback, plugin.keys.initializedCallback) // which register plugin.keys.keysdata // -// updateCallback function format: function(pluginName, fieldName, eventObejct) +// updateCallback function format: function(pluginName, fieldName, eventObejct, fullUpdated) // updateCallback will be fired when local or remote pushed update to Google Realtime API -// eventObject is a ValueChangedEvent, refer to following url +// fullUpdated is true when remote update occur during local client offline, all data is replaced by remote data +// eventObject is a ValueChangedEvent, is null if fullUpdated is true +// +// detail of ValueChangedEvent refer to following url // https://developers.google.com/drive/realtime/reference/gapi.drive.realtime.ValueChangedEvent // // initializedCallback funciton format: function(pluginName, fieldName) @@ -153,7 +156,6 @@ window.plugin.sync.RegisteredMap.prototype.searchOrCreateFile = function(callbac } window.plugin.sync.RegisteredMap.prototype.updateListener = function(e) { - console.log(e); if(!e.isLocal) { if(!window.plugin[this.pluginName][this.fieldName]) { window.plugin[this.pluginName][this.fieldName] = {}; @@ -210,6 +212,7 @@ window.plugin.sync.RegisteredMap.prototype.initialize = function(callback) { $.each(_this.map.keys(), function(ind, key) { window.plugin[_this.pluginName][_this.fieldName][key] = _this.map.get(key); }); + if(_this.callback) _this.callback(_this.pluginName, _this.fieldName, null, true); } _this.initialized = true;