@@ -308,27 +308,27 @@ class NotificationsViewModel @Inject constructor(
308
308
)
309
309
)
310
310
311
- val response = db.withTransaction {
312
- val idAbovePlaceholder = notificationsDao.getIdAbove(account.id, placeholderId)
313
- val idBelowPlaceholder = notificationsDao.getIdBelow(account.id, placeholderId)
314
- when (readingOrder) {
315
- // Using minId, loads up to LOAD_AT_ONCE statuses with IDs immediately
316
- // after minId and no larger than maxId
317
- ReadingOrder . OLDEST_FIRST -> api.notifications(
318
- maxId = idAbovePlaceholder,
319
- minId = idBelowPlaceholder ,
320
- limit = TimelineViewModel . LOAD_AT_ONCE ,
321
- excludes = excludes.value
322
- )
323
- // Using sinceId, loads up to LOAD_AT_ONCE statuses immediately before
324
- // maxId, and no smaller than minId.
325
- ReadingOrder . NEWEST_FIRST -> api.notifications(
326
- maxId = idAbovePlaceholder,
327
- sinceId = idBelowPlaceholder ,
328
- limit = TimelineViewModel . LOAD_AT_ONCE ,
329
- excludes = excludes.value
330
- )
331
- }
311
+ val (idAbovePlaceholder, idBelowPlaceholder) = db.withTransaction {
312
+ notificationsDao.getIdAbove(account.id, placeholderId) to
313
+ notificationsDao.getIdBelow(account.id, placeholderId)
314
+ }
315
+ val response = when (readingOrder) {
316
+ // Using minId, loads up to LOAD_AT_ONCE statuses with IDs immediately
317
+ // after minId and no larger than maxId
318
+ ReadingOrder . OLDEST_FIRST -> api.notifications(
319
+ maxId = idAbovePlaceholder ,
320
+ minId = idBelowPlaceholder ,
321
+ limit = TimelineViewModel . LOAD_AT_ONCE ,
322
+ excludes = excludes.value
323
+ )
324
+ // Using sinceId, loads up to LOAD_AT_ONCE statuses immediately before
325
+ // maxId, and no smaller than minId.
326
+ ReadingOrder . NEWEST_FIRST -> api.notifications(
327
+ maxId = idAbovePlaceholder ,
328
+ sinceId = idBelowPlaceholder ,
329
+ limit = TimelineViewModel . LOAD_AT_ONCE ,
330
+ excludes = excludes.value
331
+ )
332
332
}
333
333
334
334
val notifications = response.body()
0 commit comments