Merge pull request #216 from JMR-dev/perf-mailbox-list
perf(mailbox): bound paging window (maxSize) and memoize per-row timestamp
This commit was merged in pull request #216.
This commit is contained in:
@@ -97,6 +97,11 @@ class MailRepositoryImpl @Inject constructor(
|
||||
pageSize = MAILBOX_PAGE_SIZE,
|
||||
initialLoadSize = MAILBOX_PAGE_SIZE * 3,
|
||||
enablePlaceholders = false,
|
||||
// Bound the in-memory window so a deep scroll can't accumulate the whole (potentially
|
||||
// thousands-of-rows) inbox: keep ~5 pages resident and evict the rest. Must be
|
||||
// >= pageSize + 2*prefetchDistance (40 + 2*40 = 120); with placeholders off, evicted leading
|
||||
// positions drop from the loaded window and the list rendering already null-guards them.
|
||||
maxSize = MAILBOX_PAGE_SIZE * 5,
|
||||
),
|
||||
pagingSourceFactory = { messageDao.pagingUnifiedFolderSummaries(folder) },
|
||||
).flow.map { page -> page.map { it.toDomain() } }
|
||||
|
||||
@@ -549,7 +549,9 @@ private fun MessageRow(
|
||||
Spacer(Modifier.width(4.dp))
|
||||
}
|
||||
Text(
|
||||
text = formatTimestamp(message.timestampMillis),
|
||||
// remember so the relative-time string isn't re-formatted (allocating a new String
|
||||
// and reading System.currentTimeMillis()) on every recomposition of the row.
|
||||
text = remember(message.timestampMillis) { formatTimestamp(message.timestampMillis) },
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user