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:
parent
6d140d6a86
commit
30b13cbdbc
2 changed files with 20 additions and 18 deletions
web/src/app
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue