1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-05 12:34:34 +02:00

Working infinite scroll

This commit is contained in:
Philipp Heckel 2022-03-08 11:21:11 -05:00
parent 6d140d6a86
commit 30b13cbdbc
2 changed files with 20 additions and 18 deletions

View file

@ -35,18 +35,14 @@ class SubscriptionManager {
return db.subscriptions.toCollection().first(); // May be undefined
}
async getNotifications(subscriptionId, offset) {
async getNotifications(subscriptionId) {
// This is quite awkward, but it is the recommended approach as per the Dexie docs.
// It's actually fine, because the reading and filtering is quite fast. The rendering is what's
// killing performance. See https://dexie.org/docs/Collection/Collection.offset()#a-better-paging-approach
console.log(`getNotifications(${subscriptionId}, ${offset})`)
const pageSize = 2000;
return db.notifications
.orderBy("time") // Sort by time first
.filter(n => n.subscriptionId === subscriptionId)
.offset(offset)
.limit(pageSize)
.reverse()
.toArray();
}