Skip to content

Commit

Permalink
Fixed: Tweaked connection error alerts.
Browse files Browse the repository at this point in the history
Fixed: Cancel sync panel no longer shows sync option buttons.
  • Loading branch information
nero120 committed Feb 9, 2017
1 parent 2b8f787 commit d65a925
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 37 deletions.
5 changes: 3 additions & 2 deletions app.html
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ <h2>{{ vm.platform.GetConstant(vm.globals.Constants.Button_Settings_Label) }}</h
</button>
</div>
</div>
<div class="animate-fade text-center" ng-show="vm.sync.enabled() && (!vm.settings.displaySyncOptions && !vm.settings.displaySyncDataUsage)">
<div class="animate-fade text-center" ng-show="vm.sync.enabled() && (!vm.settings.displaySyncOptions && !vm.settings.displaySyncDataUsage &&
!vm.settings.service.displayCancelSyncConfirmation)">
<label>{{ vm.platform.GetConstant(vm.globals.Constants.SyncPanel_Id_Label) }}:</label>
<span id="id">{{ vm.settings.id() }}</span>
<button class="btn btn-icon btn-qrcode" title="{{ vm.platform.GetConstant(vm.globals.Constants.SyncPanel_DisplayQRCode_Label) }}"
Expand Down Expand Up @@ -547,7 +548,7 @@ <h2>{{ vm.platform.GetConstant(vm.globals.Constants.Button_Settings_Label) }}</h
</button>
</div>
</div>
<div class="animate-fade" ng-show="vm.settings.service.displayCancelSyncConfirmation">
<div class="animate-fade" ng-show="vm.sync.enabled() && vm.settings.service.displayCancelSyncConfirmation">
<div ng-bind-html="vm.platform.GetConstant(vm.globals.Constants.CancelSyncConfirmation_Message)"></div>
<div class="buttons">
<button id="btnCancelSync_Confirm" type="button" class="btn btn-default" ng-click="vm.events.syncForm_CancelSyncConfirmation_Click()" tabindex="4">
Expand Down
25 changes: 0 additions & 25 deletions js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,31 +439,6 @@ xBrowserSync.App.Global = function(platform) {
'xBrowserSync-networkDisconnected',
value);
}
},
DisconnectedAlertDisplayed: {
Get: function() {
var value;

value = platform.LocalStorage.Get(
'xBrowserSync-networkDisconnectedAlertDisplayed');

if (!value) {
return true;
}
else {
if (value === 'true') {
return true;
}
else {
return false;
}
}
},
Set: function(value) {
platform.LocalStorage.Set(
'xBrowserSync-networkDisconnectedAlertDisplayed',
value);
}
}
},
Platforms: {
Expand Down
4 changes: 2 additions & 2 deletions platform/chrome/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"message": "Previous"
},
"introPanel1_Message": {
"message": "<h4>Welcome</h4><p>Thanks for using xBrowserSync - browser syncing as it should be: secure, anonymous and free!</p><p>Have a read through the following pages to help you get started. Should you require futher help, check out the <a href='https://www.xbrowsersync.org/#faqs' class='new-tab'>FAQs</a>.</p>"
"message": "<h4>Welcome</h4><p>Thanks for using xBrowserSync &mdash; browser syncing as it should be: secure, anonymous and free!</p><p>Take some time to read through the following pages to get aquainted with xBrowserSync's features. Futher information is available in the <a href='https://www.xbrowsersync.org/#faqs' class='new-tab'>FAQs</a>.</p>"
},
"introPanel2_Message": {
"message": "<h4>Your secret word</h4><p>To begin, enter a secret word or phrase that will be used to encrypt and decrypt your browser data.</p><p>Make it strong to protect your data but also memorable, if you forget it we can't remind you and you won't be able to decrypt your data without it.</p>"
Expand All @@ -63,7 +63,7 @@
"message": "<h4>Native features supported</h4><p>Feel free to use your browser's native bookmarking features whilst synced, any changes you make will be synced automatically.</p><p>xBrowserSync will respect your existing bookmarks hierarchy, and will even add description and tags metadata to bookmarks added via the native bookmark button.</p>"
},
"introPanel9_Message": {
"message": "<h4>Adding a bookmark</h4><p>You can add the current page as a bookmark (or modify it if it is bookmarked already) by clicking on the bookmark icon in the Search panel.</p><p>Include a description which will be displayed in search results, and add tags to help find the bookmark more easily when searching.</p>"
"message": "<h4>Adding a bookmark</h4><p>Bookmark the current page by clicking on the bookmark icon in the Search panel where you can modify the description and tags &mdash; providing good metadata means more relevant results when searching.</p><p>Alternatively, simply click the default browser bookmark button as you normally would and xBrowserSync will automatically add the page's default description and tags.</p>"
},
"introPanel10_Message": {
"message": "<h4>Remember to back up</h4><p>xBrowserSync services are run voluntarily, plus servers can break and go wrong so please look after your data and make sure to keep backups.</p><p>Open the Settings panel and in the Back up and restore tab you can back up your unencrypted synced data to a local file, which can then restored at a later date should you need to.</p>"
Expand Down
32 changes: 25 additions & 7 deletions platform/chrome/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ xBrowserSync.App = xBrowserSync.App || {};
xBrowserSync.App.Background = function($q, platform, globals, utility, bookmarks) {
'use strict';

var asyncChannel, moduleName = 'xBrowserSync.App.Background', networkErrorDetected = false;
var asyncChannel, moduleName = 'xBrowserSync.App.Background', networkErrorDetected = false, checkForUpdatesAttempts = 0, disconnectedAlertDisplayed = false;

/* ------------------------------------------------------------------------------------
* Constructor
Expand Down Expand Up @@ -141,8 +141,11 @@ xBrowserSync.App.Background = function($q, platform, globals, utility, bookmarks

bookmarks.CheckForUpdates()
.then(function(syncUpdated) {
// Reset counter
checkForUpdatesAttempts = 0;

// As connection succeeded, reset network error displayed flag
globals.Network.DisconnectedAlertDisplayed.Set(false)
disconnectedAlertDisplayed = false;

// Reset network disconnected flag
globals.Network.Disconnected.Set(false);
Expand All @@ -161,16 +164,18 @@ xBrowserSync.App.Background = function($q, platform, globals, utility, bookmarks
// If network error, only display an alert on the first error, or if the user
// is pushing an update
if (!!globals.Network.Disconnected.Get()) {
checkForUpdatesAttempts++;

// Return if this is not an update and network error detected previously, or if attempting to
// sync after a previously failed attempt due to network error
if ((err.code === globals.ErrorCodes.HttpRequestFailed && !!globals.Network.DisconnectedAlertDisplayed.Get()) ||
if ((err.code === globals.ErrorCodes.HttpRequestFailed && checkForUpdatesAttempts < 3) ||
!!disconnectedAlertDisplayed ||
err.code === globals.ErrorCodes.HttpRequestFailedWhileUpdating) {
return;
}

// Set network error displayed flag
globals.Network.DisconnectedAlertDisplayed.Set(true);
}

disconnectedAlertDisplayed = true;

// Display alert
var errMessage = utility.GetErrorMessageFromException(err);
Expand Down Expand Up @@ -234,6 +239,9 @@ xBrowserSync.App.Background = function($q, platform, globals, utility, bookmarks

// Clear cached bookmarks
globals.Cache.Bookmarks.Set(null);

// Set network disconnected flag
globals.Network.Disconnected.Set(false);
}
break;
}
Expand Down Expand Up @@ -357,9 +365,16 @@ xBrowserSync.App.Background = function($q, platform, globals, utility, bookmarks
};

var syncBookmarks = function(syncData, command) {
var networkPreviouslyDisconnected = globals.Network.Disconnected.Get();

// Start sync
return bookmarks.Sync(syncData)
.then(function() {
.then(function(syncUpdated) {
// Alert the user if a previous update that failed has now synced
if (!!networkPreviouslyDisconnected && !!syncUpdated) {
displayAlert(platform.GetConstant(globals.Constants.ConnRestored_Title), platform.GetConstant(globals.Constants.ConnRestored_Message));
}

if (!!command) {
try {
asyncChannel.postMessage({ command: command, success: true });
Expand All @@ -381,6 +396,9 @@ xBrowserSync.App.Background = function($q, platform, globals, utility, bookmarks
moduleName, 'syncBookmarks', utility.LogType.Info,
'syncData: ' + JSON.stringify(syncData));

// Set flag if user has been alerted of disconnection
disconnectedAlertDisplayed = (err.code === globals.ErrorCodes.HttpRequestFailed || err.code === globals.ErrorCodes.HttpRequestFailedWhileUpdating);

if (!!command) {
try {
asyncChannel.postMessage({ command: command, success: false, error: err });
Expand Down
2 changes: 1 addition & 1 deletion platform/mobileapps/js/platformImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ xBrowserSync.App.PlatformImplementation = function($http, $interval, $q, $timeou
"message": "Previous"
},
"introPanel1_Message": {
"message": "<h4>Welcome</h4><p>Thanks for using xBrowserSync - browser syncing as it should be: secure, anonymous and free!</p><p>Have a read through the following pages to help you get started. Should you require futher help, check out the <a href='https://www.xbrowsersync.org/#faqs' class='new-tab'>FAQs</a>.</p>"
"message": "<h4>Welcome</h4><p>Thanks for using xBrowserSync &mdash; browser syncing as it should be: secure, anonymous and free!</p><p>Take some time to read through the following pages to get aquainted with xBrowserSync's features. Futher information is available in the <a href='https://www.xbrowsersync.org/#faqs' class='new-tab'>FAQs</a>.</p>"
},
"introPanel2_Message": {
"message": "<h4>Your secret word</h4><p>To begin, enter a secret word or phrase that will be used to encrypt and decrypt your browser data.</p><p>Make it strong to protect your data but also memorable, if you forget it we can't remind you and you won't be able to decrypt your data without it.</p>"
Expand Down

0 comments on commit d65a925

Please sign in to comment.