diff --git a/client/js/requests/items.ts b/client/js/requests/items.ts index c6ad7bdb6..698e5d963 100644 --- a/client/js/requests/items.ts +++ b/client/js/requests/items.ts @@ -141,6 +141,7 @@ function enrichItemsResponse(data: RawItemsResponse): ItemsResponse { type QueryFilter = { fromDatetime?: Date; + itemsPerPage?: number; }; /** diff --git a/client/js/selfoss-base.ts b/client/js/selfoss-base.ts index 1e7fa5ca1..cc4b49879 100644 --- a/client/js/selfoss-base.ts +++ b/client/js/selfoss-base.ts @@ -456,7 +456,9 @@ class selfoss { ): void { const awaitStateChange = (): void => { reg.installing.addEventListener('statechange', (event) => { - if (event.target.state === 'installed') { + // https://github.com/microsoft/TypeScript/issues/40153 + const sw = event.target as ServiceWorker; + if (sw.state === 'installed') { callback(reg); } }); diff --git a/client/js/selfoss-db-offline.ts b/client/js/selfoss-db-offline.ts index 772a55497..2bfe98eab 100644 --- a/client/js/selfoss-db-offline.ts +++ b/client/js/selfoss-db-offline.ts @@ -1,10 +1,15 @@ import selfoss from './selfoss-base'; import { OfflineStorageNotAvailableError } from './errors'; -import Dexie from 'dexie'; +import Dexie, { + PromiseExtended, + Table, + Transaction, + TransactionMode, +} from 'dexie'; import { OfflineDb } from './model/OfflineDb'; import { FilterType } from './Filter'; -const ENTRY_STATUS_NAMES = ['unread', 'starred']; +const ENTRY_STATUS_NAMES: Array<'unread' | 'starred'> = ['unread', 'starred']; export default class DbOffline { /** @var Date the datetime of the newest garbage collected entry, i.e. deleted because not of interest. */ @@ -17,25 +22,31 @@ export default class DbOffline { public olderEntriesOnline: boolean = false; public needsSync: boolean; - _tr(...args) { - return selfoss.db.storage.transaction(...args).catch((error) => { - selfoss.app.showError( - selfoss.app._('error_offline_storage', { - '0': error.message, - }), - ); - selfoss.db.broken = true; - selfoss.db.enableOffline.update(false); - selfoss.entries?.reload(); - - // If this is a QuotaExceededError, garbage collect more - // entries and hope it helps. - if (error.name === Dexie.errnames.QuotaExceeded) { - this.GCEntries(true); - } + _tr( + mode: TransactionMode, + tables: Table[], + scope: (trans: Transaction) => PromiseLike | U, + ): PromiseExtended { + return selfoss.db.storage + .transaction(mode, tables, scope) + .catch((error) => { + selfoss.app.showError( + selfoss.app._('error_offline_storage', { + '0': error.message, + }), + ); + selfoss.db.broken = true; + selfoss.db.enableOffline.update(false); + selfoss.entries?.reload(); - return Promise.reject(error); - }); + // If this is a QuotaExceededError, garbage collect more + // entries and hope it helps. + if (error.name === Dexie.errnames.QuotaExceeded) { + this.GCEntries(true); + } + + return Promise.reject(error); + }); } init() {