Merge branch 'release/1.1.3'

This commit is contained in:
Book Pauk
2023-02-06 19:47:56 +07:00
8 changed files with 201 additions and 156 deletions

View File

@@ -34,8 +34,8 @@ class LibsPage {
if (!this.mode) if (!this.mode)
return; return;
//TODO: убрать второе условие в 24г //TODO: убрать условие с mode в 24г
if (!this.libs || (this.mode === 'omnireader' && this.libs.mode !== this.mode)) { if (!this.libs || !this.libs.groups || (this.mode === 'omnireader' && this.libs.mode !== this.mode)) {
const defaults = rstore.getLibsDefaults(this.mode); const defaults = rstore.getLibsDefaults(this.mode);
this.commit('reader/setLibs', defaults); this.commit('reader/setLibs', defaults);
} }

View File

@@ -393,6 +393,9 @@ class Reader {
this.recentItemKeys = []; this.recentItemKeys = [];
//сохранение в удаленном хранилище //сохранение в удаленном хранилище
await this.$refs.serverStorage.saveRecent(itemKeys); await this.$refs.serverStorage.saveRecent(itemKeys);
//periodicTasks
this.periodicTasks();//no await
} catch (e) { } catch (e) {
if (!this.offlineModeActive) if (!this.offlineModeActive)
this.$root.notify.error(e.message); this.$root.notify.error(e.message);
@@ -442,26 +445,15 @@ class Reader {
this.$refs.recentBooksPage.init(); this.$refs.recentBooksPage.init();
})(); })();
//проверки обновлений читалки //единственный запуск periodicTasks при инициализации
//дальнейшие запуски periodicTasks выполняются из debouncedSaveRecent
//т.е. только по действию пользователя
(async() => { (async() => {
await utils.sleep(15*1000);
this.isFirstNeedUpdateNotify = true; this.isFirstNeedUpdateNotify = true;
//вечный цикл, запрашиваем периодически конфиг для проверки выхода новой версии читалки
while (1) {// eslint-disable-line no-constant-condition
await this.checkNewVersionAvailable();
await utils.sleep(60*60*1000); //каждый час
}
//дальше хода нет
})();
//проверки обновлений книг this.allowPeriodicTasks = true;
(async() => { this.periodicTasks();//no await
await utils.sleep(15*1000); //подождем неск. секунд перед первым запросом
//вечный цикл, запрашиваем периодически обновления
while (1) {// eslint-disable-line no-constant-condition
await this.checkBuc();
await utils.sleep(70*60*1000); //каждые 70 минут
}
//дальше хода нет
})(); })();
} }
@@ -560,11 +552,45 @@ class Reader {
} }
} }
async checkNewVersionAvailable() { async periodicTasks() {
if (!this.checkingNewVersion && this.showNeedUpdateNotify) { if (!this.allowPeriodicTasks || this.doingPeriodicTasks)
this.checkingNewVersion = true; return;
this.doingPeriodicTasks = true;
try { try {
await utils.sleep(15*1000); //подождем 15 секунд, чтобы прогрузился ServiceWorker при выходе новой версии if (!this.taskList) {
const taskArr = [
[this.checkNewVersionAvailable, 60], //проверки обновлений читалки, каждый час
[this.checkBuc, 70], //проверки обновлений книг, каждые 70 минут
];
this.taskList = [];
for (const task of taskArr) {
const [method, period] = task;
this.taskList.push({method, period, lastRunTime: 0});
}
}
for (const task of this.taskList) {
if (Date.now() - task.lastRunTime >= task.period*60*1000) {
try {
//console.log('task run', task.method.name);
await task.method();
} catch (e) {
console.error(e);
}
task.lastRunTime = Date.now();
}
}
} catch (e) {
console.error(e);
} finally {
this.doingPeriodicTasks = false;
}
}
async checkNewVersionAvailable() {
if (this.showNeedUpdateNotify) {
const config = await miscApi.loadConfig(); const config = await miscApi.loadConfig();
this.commit('config/setConfig', config); this.commit('config/setConfig', config);
@@ -575,11 +601,7 @@ class Reader {
if (this.version != this.clientVersion) if (this.version != this.clientVersion)
this.$root.notify.info(`Вышла новая версия (v${this.version}) читалки.<br>Пожалуйста, обновите страницу${againMes}.`, 'Обновление'); this.$root.notify.info(`Вышла новая версия (v${this.version}) читалки.<br>Пожалуйста, обновите страницу${againMes}.`, 'Обновление');
} catch(e) {
console.error(e);
} finally {
this.checkingNewVersion = false;
}
this.isFirstNeedUpdateNotify = false; this.isFirstNeedUpdateNotify = false;
} }
} }
@@ -588,7 +610,6 @@ class Reader {
if (!this.bothBucEnabled) if (!this.bothBucEnabled)
return; return;
try {
const sorted = bookManager.getSortedRecent(); const sorted = bookManager.getSortedRecent();
//выберем все кандидиаты на обновление //выберем все кандидиаты на обновление
@@ -661,9 +682,6 @@ class Reader {
} }
await this.$refs.recentBooksPage.updateTableData(); await this.$refs.recentBooksPage.updateTableData();
} catch (e) {
console.error(e);
}
} }
updateCountChanged(event) { updateCountChanged(event) {
@@ -1409,8 +1427,6 @@ class Reader {
if (!this.showHelpOnErrorIfNeeded(url)) { if (!this.showHelpOnErrorIfNeeded(url)) {
this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'}); this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
} }
} finally {
this.checkNewVersionAvailable();
} }
} }

View File

@@ -22,9 +22,11 @@ const ssCacheStore = localForage.createInstance({
const componentOptions = { const componentOptions = {
watch: { watch: {
serverSyncEnabled: function() { serverSyncEnabled: function() {
if (this.inited)
this.serverSyncEnabledChanged(); this.serverSyncEnabledChanged();
}, },
serverStorageKey: function() { serverStorageKey: function() {
if (this.inited)
this.serverStorageKeyChanged(true); this.serverStorageKeyChanged(true);
}, },
settings: function() { settings: function() {
@@ -85,6 +87,13 @@ class ServerStorage {
if (!this.cachedRecentMod) if (!this.cachedRecentMod)
await this.cleanCachedRecent('cachedRecentMod'); await this.cleanCachedRecent('cachedRecentMod');
//подстраховка хранения ключа, восстановим из IndexedDB при проблемах в localStorage
if (!this.serverStorageKey) {
const key = await ssCacheStore.getItem('storageKey');
if (key)
this.commit('reader/setServerStorageKey', key);
}
if (!this.serverStorageKey) { if (!this.serverStorageKey) {
//генерируем новый ключ //генерируем новый ключ
await this.generateNewServerStorageKey(); await this.generateNewServerStorageKey();
@@ -123,6 +132,7 @@ class ServerStorage {
async generateNewServerStorageKey() { async generateNewServerStorageKey() {
const key = utils.toBase58(utils.randomArray(32)); const key = utils.toBase58(utils.randomArray(32));
this.commit('reader/setServerStorageKey', key); this.commit('reader/setServerStorageKey', key);
//дождемся serverStorageKeyChanged, событие по watch не работает при this.inited == false
await this.serverStorageKeyChanged(true); await this.serverStorageKeyChanged(true);
} }
@@ -141,6 +151,10 @@ class ServerStorage {
async serverStorageKeyChanged(force) { async serverStorageKeyChanged(force) {
if (this.prevServerStorageKey != this.serverStorageKey) { if (this.prevServerStorageKey != this.serverStorageKey) {
this.prevServerStorageKey = this.serverStorageKey; this.prevServerStorageKey = this.serverStorageKey;
//сохраним ключ также в IndexedDB, чтобы была возможность восстановить при проблемах с localStorage
await ssCacheStore.setItem('storageKey', this.serverStorageKey);
this.hashedStorageKey = utils.toBase58(cryptoUtils.sha256(this.serverStorageKey)); this.hashedStorageKey = utils.toBase58(cryptoUtils.sha256(this.serverStorageKey));
this.keyInited = true; this.keyInited = true;

View File

@@ -438,7 +438,8 @@ export default class BookParser {
}; };
const onEndNode = (elemName) => {// eslint-disable-line no-unused-vars const onEndNode = (elemName) => {// eslint-disable-line no-unused-vars
if (tag == elemName) { tag = elemName;
if (tag == 'binary') { if (tag == 'binary') {
binaryId = ''; binaryId = '';
} }
@@ -486,14 +487,15 @@ export default class BookParser {
} }
} }
path = path.substr(0, path.length - tag.length - 1); let i = path.lastIndexOf(tag);
let i = path.lastIndexOf('/');
if (i >= 0) { if (i >= 0) {
tag = path.substr(i + 1); path = path.substring(0, i - 1);
} else { i = path.lastIndexOf('/');
if (i >= 0)
tag = path.substring(i + 1);
else
tag = path; tag = path;
} }
}
}; };
const onTextNode = (text) => {// eslint-disable-line no-unused-vars const onTextNode = (text) => {// eslint-disable-line no-unused-vars

View File

@@ -1,4 +1,17 @@
export const versionHistory = [ export const versionHistory = [
{
version: '1.1.3',
releaseDate: '2023-02-06',
showUntil: '2023-02-05',
content:
`
<ul>
<li>исправление багов</li>
</ul>
`
},
{ {
version: '1.1.2', version: '1.1.2',
releaseDate: '2023-01-22', releaseDate: '2023-01-22',

View File

@@ -325,7 +325,7 @@ const state = {
currentProfile: '', currentProfile: '',
settings: _.cloneDeep(settingDefaults), settings: _.cloneDeep(settingDefaults),
settingsRev: {}, settingsRev: {},
libs: false, libs: {},
libsRev: 0, libsRev: 0,
}; };

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "liberama", "name": "liberama",
"version": "1.1.2", "version": "1.1.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "liberama", "name": "liberama",
"version": "1.1.2", "version": "1.1.3",
"hasInstallScript": true, "hasInstallScript": true,
"license": "CC0-1.0", "license": "CC0-1.0",
"dependencies": { "dependencies": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "liberama", "name": "liberama",
"version": "1.1.2", "version": "1.1.3",
"author": "Book Pauk <bookpauk@gmail.com>", "author": "Book Pauk <bookpauk@gmail.com>",
"license": "CC0-1.0", "license": "CC0-1.0",
"repository": "bookpauk/liberama", "repository": "bookpauk/liberama",