Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
improve backoff presentation [#192]
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-weber committed Aug 5, 2018
1 parent 19aab82 commit 2447d47
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,16 @@ function main() {
if (!syncMs) {
nextExpectedSync = null;
}
// This can mutate backoffStart, so it needs to be explicitly run before accessing it.
const inBackoff = manager.inBackoff();
sendResponse({
lastPSync,
nextExpectedSync,
lastSyncInfo,
'randomCacheTS': Track.randomCacheTS,
inBackoff: manager.inBackoff(),
inBackoff,
backoffStartMs: manager.backoffStart ? manager.backoffStart.valueOf() : null,
backoffMins: Syncing.BACKOFF_MINS,
});
});
});
Expand Down
3 changes: 2 additions & 1 deletion src/js/syncing.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const Reporting = require('./reporting');
// This is being used to hold the old global state moving out of background.
const globalState = {};

const BACKOFF_MINS = 15;
const BACKOFF_MINS = 30;

class Manager {
// A sync manager serializes access to both remote and local (cached) Music resources.
Expand Down Expand Up @@ -185,6 +185,7 @@ class Manager {
}

exports.Manager = Manager;
exports.BACKOFF_MINS = BACKOFF_MINS;

function sync(details, batchingEnabled) {
// Promise a list of api responses.
Expand Down
9 changes: 6 additions & 3 deletions src/js/syncpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const moment = require('moment');
const Reporting = require('./reporting');

const SUPPORT_LINK = 'https://github.com/simon-weber/Autoplaylists-for-Google-Music/wiki';
const SYNCING_GUIDE_LINK = 'https://github.com/simon-weber/Autoplaylists-for-Google-Music/wiki/Debugging#handling-syncing-failures-or-an-overloaded-account';

/* eslint-disable */
// https://gist.github.com/kerimdzhanov/f6f0d2b2a57720426211
Expand Down Expand Up @@ -43,13 +44,15 @@ function onReady() {

let nextSyncInfo = 'Periodic syncing is disabled.';
if (status.inBackoff) {
nextSyncInfo = 'Periodic syncing has been temporarily disabled since your account is showing signs of being overloaded.'
+ ' Syncing will resume in 30 minutes.';
const backoffEndsIn = moment(new Date(status.backoffStartMs + (status.backoffMins * 60 * 1000))).fromNow();
nextSyncInfo = 'Periodic syncing is temporarily disabled since Google'
+ ` is <a href="${SYNCING_GUIDE_LINK}">showing signs of being overloaded</a>.`
+ `<br/>Syncing will be enabled again ${backoffEndsIn}.`;
$('#sync-now').attr('disabled', true);
} else if (status.nextExpectedSync) {
nextSyncInfo = `The next full sync is expected ${moment(new Date(status.nextExpectedSync)).fromNow()}.`;
}
$('#next-sync-info').text(nextSyncInfo);
$('#next-sync-info').html(nextSyncInfo);
});

$('#sync-now').click(e => {
Expand Down

0 comments on commit 2447d47

Please sign in to comment.