Last active
August 29, 2015 14:04
-
-
Save vratiu/6a6ff42ade5f97eb90f3 to your computer and use it in GitHub Desktop.
buildFileURL clear cache fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/sugarapi/sugarapi.js b/lib/sugarapi/sugarapi.js | |
index e2c2b86..a052b95 100644 | |
--- a/lib/sugarapi/sugarapi.js | |
+++ b/lib/sugarapi/sugarapi.js | |
@@ -270,6 +270,8 @@ SUGAR.Api = (function() { | |
_accessToken = null, | |
_refreshToken = null, | |
_downloadToken = null, | |
+ //Api Initialization time | |
+ _apiInitTime = null, | |
// request queue | |
// used to support multiple request while in refresh token loop | |
_rqueue = [], | |
@@ -303,6 +305,15 @@ SUGAR.Api = (function() { | |
callback(["AuthAccessToken", "AuthRefreshToken", "DownloadToken"]); | |
}); | |
} | |
+ | |
+ | |
+ //Create or use existing Api initialization time | |
+ if(_keyValueStore.get("ApiInitTime")){ | |
+ _apiInitTime = _keyValueStore.get("ApiInitTime"); | |
+ }else{ | |
+ _apiInitTime = (new Date()).getTime() | |
+ _keyValueStore.set("ApiInitTime", _apiInitTime); | |
+ } | |
} | |
_refreshingToken = false; | |
@@ -706,6 +717,7 @@ SUGAR.Api = (function() { | |
* @member SUGAR.Api | |
*/ | |
buildFileURL: function(attributes, options) { | |
var params = {}; | |
options = options || {}; | |
// We only concerned about the format if build URL for an actual file resource | |
@@ -731,7 +743,7 @@ SUGAR.Api = (function() { | |
} | |
if (options.cleanCache === true) { | |
- params[(new Date()).getTime()] = 1; | |
+ params[this.getApiInitTime()] = 1; | |
} | |
if (options.platform !== undefined) { | |
@@ -757,6 +769,10 @@ SUGAR.Api = (function() { | |
return _keyValueStore ? _keyValueStore.get("AuthRefreshToken") || _refreshToken : _refreshToken; | |
}, | |
+ getApiInitTime: function() { | |
+ return _keyValueStore ? _keyValueStore.get("ApiInitTime") || _apiInitTime: _apiInitTime; | |
+ }, | |
+ | |
/** | |
* Returns the current download token. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment