Limit amount of updates loaded for widget

Probably fixes #9868
This commit is contained in:
arkon
2023-08-27 22:05:52 -04:00
parent 98d6ce2eaf
commit 87530f506e
5 changed files with 28 additions and 26 deletions

View File

@@ -9,11 +9,12 @@ class UpdatesRepositoryImpl(
private val databaseHandler: DatabaseHandler,
) : UpdatesRepository {
override suspend fun awaitWithRead(read: Boolean, after: Long): List<UpdatesWithRelations> {
override suspend fun awaitWithRead(read: Boolean, after: Long, limit: Long): List<UpdatesWithRelations> {
return databaseHandler.awaitList {
updatesViewQueries.getUpdatesByReadStatus(
read = read,
after = after,
limit = limit,
mapper = updateWithRelationMapper,
)
}
@@ -25,11 +26,12 @@ class UpdatesRepositoryImpl(
}
}
override fun subscribeWithRead(read: Boolean, after: Long): Flow<List<UpdatesWithRelations>> {
override fun subscribeWithRead(read: Boolean, after: Long, limit: Long): Flow<List<UpdatesWithRelations>> {
return databaseHandler.subscribeToList {
updatesViewQueries.getUpdatesByReadStatus(
read = read,
after = after,
limit = limit,
mapper = updateWithRelationMapper,
)
}

View File

@@ -30,4 +30,5 @@ getUpdatesByReadStatus:
SELECT *
FROM updatesView
WHERE read = :read
AND dateUpload > :after;
AND dateUpload > :after
LIMIT :limit;