Sync reminders changes (#2354)
- Always wait seven days, standardize casing - Enable auto-sync without opening preferences - Implement suggestions
This commit is contained in:
parent
1a3f6301b7
commit
b0f09b3a86
4 changed files with 91 additions and 70 deletions
|
@ -254,10 +254,10 @@ Zotero.Prefs = new function(){
|
||||||
Zotero.Sync.EventListeners.IdleListener.unregister();
|
Zotero.Sync.EventListeners.IdleListener.unregister();
|
||||||
Zotero.Prefs.set('sync.reminder.autoSync.enabled', true);
|
Zotero.Prefs.set('sync.reminder.autoSync.enabled', true);
|
||||||
// We don't want to immediately display reminder so bump this value
|
// We don't want to immediately display reminder so bump this value
|
||||||
Zotero.Prefs.set('sync.reminder.autoSync.lastDisplayed', String(Date.now()));
|
Zotero.Prefs.set('sync.reminder.autoSync.lastDisplayed', Math.round(Date.now() / 1000));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Zotero.getActiveZoteroPane().setupSyncReminders(false);
|
Zotero.getActiveZoteroPane().initSyncReminders(false);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
Zotero.logError(e);
|
Zotero.logError(e);
|
||||||
|
|
|
@ -229,7 +229,7 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
ZoteroPane.showRetractionBanner();
|
ZoteroPane.showRetractionBanner();
|
||||||
ZoteroPane.setupSyncReminders(true);
|
ZoteroPane.initSyncReminders(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TEMP: Clean up extra files from Mendeley imports <5.0.51
|
// TEMP: Clean up extra files from Mendeley imports <5.0.51
|
||||||
|
@ -2266,27 +2266,29 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
|
|
||||||
this._syncRemindersObserverID = null;
|
this._syncRemindersObserverID = null;
|
||||||
this.setupSyncReminders = function (startup) {
|
this.initSyncReminders = function (startup) {
|
||||||
if (startup) {
|
if (startup) {
|
||||||
Zotero.Notifier.registerObserver(
|
Zotero.Notifier.registerObserver(
|
||||||
{ notify: (event) => {
|
{
|
||||||
// When the API Key is deleted we need to add an observer
|
notify: (event) => {
|
||||||
if (event === 'delete') {
|
// When the API Key is deleted we need to add an observer
|
||||||
Zotero.Prefs.set('sync.reminder.setup.enabled', true);
|
if (event === 'delete') {
|
||||||
Zotero.Prefs.set('sync.reminder.setup.lastDisplayed', String(Date.now()));
|
Zotero.Prefs.set('sync.reminder.setUp.enabled', true);
|
||||||
ZoteroPane.setupSyncReminders(false);
|
Zotero.Prefs.set('sync.reminder.setUp.lastDisplayed', Math.round(Date.now() / 1000));
|
||||||
|
ZoteroPane.initSyncReminders(false);
|
||||||
|
}
|
||||||
|
// When API Key is added we can remove the observer
|
||||||
|
else if (event === 'add') {
|
||||||
|
ZoteroPane.initSyncReminders(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// When API Key is added we can remove the observer
|
},
|
||||||
else if (event === 'add') {
|
|
||||||
ZoteroPane.setupSyncReminders(false);
|
|
||||||
}
|
|
||||||
} },
|
|
||||||
'api-key');
|
'api-key');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If both reminders are disabled, we don't need an observer
|
// If both reminders are disabled, we don't need an observer
|
||||||
if (!Zotero.Prefs.get('sync.reminder.setup.enabled')
|
if (!Zotero.Prefs.get('sync.reminder.setUp.enabled')
|
||||||
&& !Zotero.Prefs.get('sync.reminder.autoSync.enabled')) {
|
&& !Zotero.Prefs.get('sync.reminder.autoSync.enabled')) {
|
||||||
if (this._syncRemindersObserverID) {
|
if (this._syncRemindersObserverID) {
|
||||||
Zotero.Notifier.unregisterObserver(this._syncRemindersObserverID);
|
Zotero.Notifier.unregisterObserver(this._syncRemindersObserverID);
|
||||||
this._syncRemindersObserverID = null;
|
this._syncRemindersObserverID = null;
|
||||||
|
@ -2310,37 +2312,64 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
const eventTypes = ['add', 'modify', 'delete'];
|
const eventTypes = ['add', 'modify', 'delete'];
|
||||||
this._syncRemindersObserverID = Zotero.Notifier.registerObserver(
|
this._syncRemindersObserverID = Zotero.Notifier.registerObserver(
|
||||||
{ notify: (event) => {
|
{
|
||||||
if (!eventTypes.includes(event)) {
|
notify: (event) => {
|
||||||
return;
|
if (!eventTypes.includes(event)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
this.showSetUpSyncReminder();
|
||||||
|
this.showAutoSyncReminder();
|
||||||
|
}, 5000);
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
},
|
||||||
this.showSetupSyncReminder();
|
|
||||||
this.showAutoSyncOffReminder();
|
|
||||||
}, 5000);
|
|
||||||
} },
|
|
||||||
'item',
|
'item',
|
||||||
'syncReminder');
|
'syncReminder');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.showAutoSyncOffReminder = function () {
|
this.showSetUpSyncReminder = function () {
|
||||||
|
const sevenDays = 60 * 60 * 24 * 7;
|
||||||
|
|
||||||
|
// Reasons not to show reminder:
|
||||||
|
// - User turned reminder off
|
||||||
|
// - Sync is enabled
|
||||||
|
if (!Zotero.Prefs.get('sync.reminder.setUp.enabled')
|
||||||
|
|| Zotero.Sync.Runner.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check lastDisplayed was 7+ days ago
|
||||||
|
let lastDisplayed = Zotero.Prefs.get('sync.reminder.setUp.lastDisplayed');
|
||||||
|
if (lastDisplayed > Math.round(Date.now() / 1000) - sevenDays) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// When we have not seen the first warning, hide the checkbox
|
||||||
|
this.showSyncReminder('setUp', lastDisplayed === 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.showAutoSyncReminder = function () {
|
||||||
|
const sevenDays = 60 * 60 * 24 * 7;
|
||||||
|
|
||||||
// Reasons not to show reminder:
|
// Reasons not to show reminder:
|
||||||
// - User turned reminder off
|
// - User turned reminder off
|
||||||
// - Sync is not enabled
|
// - Sync is not enabled
|
||||||
// - Auto-Sync is enabled
|
// - Auto-Sync is enabled
|
||||||
// - Last sync for all libraries was within 30 days
|
// - Last sync for all libraries was within 7 days
|
||||||
if (!Zotero.Prefs.get('sync.reminder.autoSync.enabled')
|
if (!Zotero.Prefs.get('sync.reminder.autoSync.enabled')
|
||||||
|| !Zotero.Sync.Runner.enabled
|
|| !Zotero.Sync.Runner.enabled
|
||||||
|| Zotero.Prefs.get('sync.autoSync')
|
|| Zotero.Prefs.get('sync.autoSync')
|
||||||
|| !Zotero.Libraries.getAll()
|
|| Zotero.Libraries.getAll()
|
||||||
.find(library => library.lastSync.getTime() < (Date.now() - 2592000000))) {
|
.every(library => !library.syncable
|
||||||
|
|| library.lastSync.getTime() > Date.now() - 1000 * sevenDays)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check lastDisplayed was 30+ days ago
|
// Check lastDisplayed was 7+ days ago
|
||||||
let lastDisplayed = parseInt(Zotero.Prefs.get(`sync.reminder.autoSync.lastDisplayed`));
|
let lastDisplayed = Zotero.Prefs.get('sync.reminder.autoSync.lastDisplayed');
|
||||||
if (lastDisplayed > (Date.now() - 2592000000)) {
|
if (lastDisplayed > Math.round(Date.now() / 1000) - sevenDays) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2348,41 +2377,25 @@ var ZoteroPane = new function()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
this.showSetupSyncReminder = function () {
|
|
||||||
// Reasons not to show reminder:
|
|
||||||
// - User turned reminder off
|
|
||||||
// - Sync is enabled
|
|
||||||
if (!Zotero.Prefs.get('sync.reminder.setup.enabled')
|
|
||||||
|| Zotero.Sync.Runner.enabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check lastDisplayed was 7+ days ago
|
|
||||||
let lastDisplayed = parseInt(Zotero.Prefs.get(`sync.reminder.setup.lastDisplayed`));
|
|
||||||
if (lastDisplayed > (Date.now() - 604800000)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When we have not seen the first warning, hide the checkbox
|
|
||||||
this.showSyncReminder('setup', lastDisplayed === 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the UI and show the sync reminder panel for a given type of reminder
|
* Configure the UI and show the sync reminder panel for a given type of reminder
|
||||||
*
|
*
|
||||||
* @param reminderType - Possible values: 'setup' or 'autoSync'
|
* @param reminderType - Possible values: 'setUp' or 'autoSync'
|
||||||
* @param hideDisable - True if the 'Don't show again' link is hidden
|
* @param hideDisable - True if the 'Don't show again' link is hidden
|
||||||
*/
|
*/
|
||||||
this.showSyncReminder = function (reminderType, hideDisable) {
|
this.showSyncReminder = function (reminderType, hideDisable) {
|
||||||
|
if (!['setUp', 'autoSync'].includes(reminderType)) {
|
||||||
|
throw new Error(`Invalid reminder type: ${reminderType}`);
|
||||||
|
}
|
||||||
|
|
||||||
let panel = document.getElementById('sync-reminder-container');
|
let panel = document.getElementById('sync-reminder-container');
|
||||||
const closePanel = function () {
|
const closePanel = function () {
|
||||||
panel.setAttribute('collapsed', true);
|
panel.setAttribute('collapsed', true);
|
||||||
Zotero.Prefs.set(`sync.reminder.${reminderType}.lastDisplayed`, String(Date.now()));
|
Zotero.Prefs.set(`sync.reminder.${reminderType}.lastDisplayed`, Math.round(Date.now() / 1000));
|
||||||
};
|
};
|
||||||
|
|
||||||
let message = document.getElementById('sync-reminder-message');
|
let message = document.getElementById('sync-reminder-message');
|
||||||
message.textContent = Zotero.getString(`sync.reminder.${reminderType}.message`);
|
message.textContent = Zotero.getString(`sync.reminder.${reminderType}.message`, Zotero.appName);
|
||||||
message.onclick = function () {
|
message.onclick = function () {
|
||||||
closePanel();
|
closePanel();
|
||||||
Zotero.Utilities.Internal.openPreferences('zotero-prefpane-sync');
|
Zotero.Utilities.Internal.openPreferences('zotero-prefpane-sync');
|
||||||
|
@ -2392,21 +2405,29 @@ var ZoteroPane = new function()
|
||||||
actionLink.textContent = Zotero.getString(`sync.reminder.${reminderType}.action`);
|
actionLink.textContent = Zotero.getString(`sync.reminder.${reminderType}.action`);
|
||||||
actionLink.onclick = function () {
|
actionLink.onclick = function () {
|
||||||
closePanel();
|
closePanel();
|
||||||
Zotero.Utilities.Internal.openPreferences('zotero-prefpane-sync');
|
|
||||||
|
switch (reminderType) {
|
||||||
|
case 'setUp':
|
||||||
|
Zotero.Utilities.Internal.openPreferences('zotero-prefpane-sync');
|
||||||
|
break;
|
||||||
|
case 'autoSync':
|
||||||
|
Zotero.Prefs.set(`sync.autoSync`, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let dontShowAgainLink = document.getElementById('sync-reminder-disable');
|
let dontShowAgainLink = document.getElementById('sync-reminder-disable');
|
||||||
dontShowAgainLink.textContent = Zotero.getString('general.dontAskMeAgain');
|
dontShowAgainLink.textContent = Zotero.getString('general.dontAskAgain');
|
||||||
dontShowAgainLink.hidden = hideDisable;
|
dontShowAgainLink.hidden = hideDisable;
|
||||||
dontShowAgainLink.onclick = function () {
|
dontShowAgainLink.onclick = function () {
|
||||||
closePanel();
|
closePanel();
|
||||||
Zotero.Prefs.set(`sync.reminder.${reminderType}.enabled`, false);
|
Zotero.Prefs.set(`sync.reminder.${reminderType}.enabled`, false);
|
||||||
// Check if we no longer need to observe item modifications
|
// Check if we no longer need to observe item modifications
|
||||||
ZoteroPane.setupSyncReminders(false);
|
ZoteroPane.initSyncReminders(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
let remindMeLink = document.getElementById('sync-reminder-remind');
|
let remindMeLink = document.getElementById('sync-reminder-remind');
|
||||||
remindMeLink.textContent = Zotero.getString('sync.reminder.remindMeLater');
|
remindMeLink.textContent = Zotero.getString('general.remindMeLater');
|
||||||
remindMeLink.onclick = function () {
|
remindMeLink.onclick = function () {
|
||||||
closePanel();
|
closePanel();
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,6 @@ extensions.zotero@chnm.gmu.edu.description = The Next-Generation Research Tool
|
||||||
general.success = Success
|
general.success = Success
|
||||||
general.error = Error
|
general.error = Error
|
||||||
general.warning = Warning
|
general.warning = Warning
|
||||||
general.dontAskMeAgain = Don't ask me again
|
|
||||||
general.dontShowWarningAgain = Don't show this warning again.
|
general.dontShowWarningAgain = Don't show this warning again.
|
||||||
general.dontShowAgainFor = Don’t show again today;Don’t show again for %1$S days
|
general.dontShowAgainFor = Don’t show again today;Don’t show again for %1$S days
|
||||||
general.browserIsOffline = %S is currently in offline mode.
|
general.browserIsOffline = %S is currently in offline mode.
|
||||||
|
@ -65,7 +64,9 @@ general.numMore = %S more…
|
||||||
general.openPreferences = Open Preferences
|
general.openPreferences = Open Preferences
|
||||||
general.keys.ctrlShift = Ctrl+Shift+
|
general.keys.ctrlShift = Ctrl+Shift+
|
||||||
general.keys.cmdShift = Cmd+Shift+
|
general.keys.cmdShift = Cmd+Shift+
|
||||||
general.dontShowAgain = Don’t Show Again
|
general.dontShowAgain = Don’t Show Again
|
||||||
|
general.dontAskAgain = Don’t Ask Again
|
||||||
|
general.remindMeLater = Remind Me Later
|
||||||
general.fix = Fix…
|
general.fix = Fix…
|
||||||
general.tryAgain = Try Again
|
general.tryAgain = Try Again
|
||||||
general.tryLater = Try Later
|
general.tryLater = Try Later
|
||||||
|
@ -994,11 +995,10 @@ sync.resetGroupFilesAndSync = Reset Group Files and Sync
|
||||||
sync.skipGroup = Skip Group
|
sync.skipGroup = Skip Group
|
||||||
sync.removeGroupsAndSync = Remove Groups and Sync
|
sync.removeGroupsAndSync = Remove Groups and Sync
|
||||||
|
|
||||||
sync.reminder.setup.message = Back up your library with Zotero syncing.
|
sync.reminder.setUp.message = Back up your library with %S syncing.
|
||||||
sync.reminder.setup.action = Set Up Syncing
|
sync.reminder.setUp.action = Set Up Syncing
|
||||||
sync.reminder.autoSync.message = Zotero can automatically sync after you make changes.
|
sync.reminder.autoSync.message = %S can automatically sync after you make changes.
|
||||||
sync.reminder.autoSync.action = Enable Automatic Sync
|
sync.reminder.autoSync.action = Enable Automatic Sync
|
||||||
sync.reminder.remindMeLater = Remind Me Later
|
|
||||||
|
|
||||||
sync.error.usernameNotSet = Username not set
|
sync.error.usernameNotSet = Username not set
|
||||||
sync.error.usernameNotSet.text = You must enter your zotero.org username and password in the Zotero preferences to sync with the Zotero server.
|
sync.error.usernameNotSet.text = You must enter your zotero.org username and password in the Zotero preferences to sync with the Zotero server.
|
||||||
|
|
|
@ -160,10 +160,10 @@ pref("extensions.zotero.sync.storage.groups.enabled", true);
|
||||||
pref("extensions.zotero.sync.storage.downloadMode.personal", "on-sync");
|
pref("extensions.zotero.sync.storage.downloadMode.personal", "on-sync");
|
||||||
pref("extensions.zotero.sync.storage.downloadMode.groups", "on-sync");
|
pref("extensions.zotero.sync.storage.downloadMode.groups", "on-sync");
|
||||||
pref("extensions.zotero.sync.fulltext.enabled", true);
|
pref("extensions.zotero.sync.fulltext.enabled", true);
|
||||||
pref("extensions.zotero.sync.reminder.setup.enabled", true);
|
pref("extensions.zotero.sync.reminder.setUp.enabled", true);
|
||||||
pref("extensions.zotero.sync.reminder.setup.lastDisplayed", "0");
|
pref("extensions.zotero.sync.reminder.setUp.lastDisplayed", 0);
|
||||||
pref("extensions.zotero.sync.reminder.autoSync.enabled", true);
|
pref("extensions.zotero.sync.reminder.autoSync.enabled", true);
|
||||||
pref("extensions.zotero.sync.reminder.autoSync.lastDisplayed", "0");
|
pref("extensions.zotero.sync.reminder.autoSync.lastDisplayed", 0);
|
||||||
|
|
||||||
// Proxy
|
// Proxy
|
||||||
pref("extensions.zotero.proxies.autoRecognize", true);
|
pref("extensions.zotero.proxies.autoRecognize", true);
|
||||||
|
|
Loading…
Reference in a new issue