Keep update date in title

This commit is contained in:
Ilya Ig. Petrov 2017-06-01 18:15:15 +05:00
parent 8ea949ac9d
commit 696983f863
3 changed files with 15 additions and 2 deletions

View File

@ -188,6 +188,7 @@
window.apis = { window.apis = {
version: { version: {
ifMini: false, ifMini: false,
build: chrome.runtime.getManifest().version.replace(/\d+\.\d+\./g, ''),
}, },
}; };

View File

@ -61,7 +61,7 @@
const ifPrefix = 'if-on-'; const ifPrefix = 'if-on-';
const extName = chrome.runtime.getManifest().name; const extName = chrome.runtime.getManifest().name;
const extVersion = chrome.runtime.getManifest().version.replace(/\d+\.\d+\./g, ''); const extVersion = window.apis.version.build;
window.apis.errorHandlers = { window.apis.errorHandlers = {

View File

@ -225,6 +225,16 @@
ifFirstInstall: false, ifFirstInstall: false,
lastPacUpdateStamp: 0, lastPacUpdateStamp: 0,
setTitle() {
const upDate = new Date(this.lastPacUpdateStamp).toLocaleString('ru-RU')
.replace(/:\d+$/, '');
chrome.browserAction.setTitle({
title: `Обновлялись ${upDate} | Версия ${window.apis.version.build}`,
});
},
_currentPacProviderLastModified: 0, // Not initialized. _currentPacProviderLastModified: 0, // Not initialized.
getLastModifiedForKey(key = mandatory()) { getLastModifiedForKey(key = mandatory()) {
@ -331,6 +341,7 @@
this.lastPacUpdateStamp = Date.now(); this.lastPacUpdateStamp = Date.now();
this.ifFirstInstall = false; this.ifFirstInstall = false;
this.setAlarms(); this.setAlarms();
this.setTitle();
} }
resolve([err, null, ...warns]); resolve([err, null, ...warns]);
@ -509,10 +520,10 @@
2. We have to check storage for migration before using it. 2. We have to check storage for migration before using it.
Better on each launch then on each pull. Better on each launch then on each pull.
*/ */
const ifUpdating = antiCensorRu.version !== oldStorage.version;
await new Promise((resolve) => { await new Promise((resolve) => {
const ifUpdating = antiCensorRu.version !== oldStorage.version;
if (!ifUpdating) { if (!ifUpdating) {
// LAUNCH, RELOAD, ENABLE // LAUNCH, RELOAD, ENABLE
@ -549,6 +560,7 @@
if (antiCensorRu.getPacProvider()) { if (antiCensorRu.getPacProvider()) {
antiCensorRu.setAlarms(); antiCensorRu.setAlarms();
} }
antiCensorRu.setTitle();
/* /*
History of Changes to Storage (Migration Guide) History of Changes to Storage (Migration Guide)