Skip to content
This repository was archived by the owner on Oct 2, 2018. It is now read-only.

Commit 320cb4b

Browse files
committed
Don't spam notifications on repeated network error
1 parent af213c0 commit 320cb4b

1 file changed

Lines changed: 27 additions & 22 deletions

File tree

scripts/cloud/cloud_dropbox.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ cloud.dropbox = {};
1313

1414
// Dropbox
1515
cloud.dropbox.client = undefined;
16+
var authError;
1617

1718

1819
/* Auth
@@ -32,9 +33,12 @@ cloud.dropbox.init = function(callback){
3233

3334
// Error Handler
3435
cloud.dropbox.auth.onError.addListener(function (error) {
35-
if (window.console) {
36-
console.error(error);
36+
if (!authError || error.status !== Dropbox.ApiError.NETWORK_ERROR) {
37+
if (window.console) {
38+
console.error(error);
39+
}
3740
cloud.dropbox.error(error);
41+
authError = true;
3842
}
3943
});
4044

@@ -45,6 +49,7 @@ cloud.dropbox.init = function(callback){
4549
if (!error && client) {
4650
// Set client
4751
cloud.dropbox.client = client;
52+
authError = false;
4853

4954
// Send success message
5055
window.dispatchEvent(cloud.dropbox.auth.onAuth);
@@ -187,25 +192,25 @@ cloud.dropbox.delete = function (path) {
187192
------------------------*/
188193
cloud.dropbox.error = function (error) {
189194
switch (error.status) {
190-
case Dropbox.ApiError.OVER_QUOTA:
191-
// The user is over their Dropbox quota.
192-
// Tell them their Dropbox is full. Refreshing the page won't help.
193-
firetext.notify(navigator.mozL10n.get('dropbox-full'));
194-
break;
195-
196-
197-
case Dropbox.ApiError.NETWORK_ERROR:
198-
firetext.notify(navigator.mozL10n.get('network-error'));
199-
break;
200-
201-
case Dropbox.ApiError.RATE_LIMITED:
202-
case Dropbox.ApiError.INVALID_TOKEN:
203-
case Dropbox.ApiError.INVALID_PARAM:
204-
case Dropbox.ApiError.OAUTH_ERROR:
205-
case Dropbox.ApiError.INVALID_METHOD:
206-
case 404:
207-
default:
208-
// TBD Code to Notify Fireanalytic
209-
break;
195+
case Dropbox.ApiError.OVER_QUOTA:
196+
// The user is over their Dropbox quota.
197+
// Tell them their Dropbox is full. Refreshing the page won't help.
198+
firetext.notify(navigator.mozL10n.get('dropbox-full'));
199+
break;
200+
201+
202+
case Dropbox.ApiError.NETWORK_ERROR:
203+
firetext.notify(navigator.mozL10n.get('network-error'));
204+
break;
205+
206+
case Dropbox.ApiError.RATE_LIMITED:
207+
case Dropbox.ApiError.INVALID_TOKEN:
208+
case Dropbox.ApiError.INVALID_PARAM:
209+
case Dropbox.ApiError.OAUTH_ERROR:
210+
case Dropbox.ApiError.INVALID_METHOD:
211+
case 404:
212+
default:
213+
// TBD Code to Notify Fireanalytic
214+
break;
210215
}
211216
};

0 commit comments

Comments
 (0)