Adjusting Post Lists to 1000 and simplifying comparisons to know when the list has changed.

This commit is contained in:
Vitor Pamplona
2023-02-14 12:08:35 -05:00
parent 6a05039bde
commit e381e2f05f
3 changed files with 8 additions and 5 deletions

View File

@@ -53,14 +53,14 @@ class NostrChatroomListNewFeedViewModel: FeedViewModel(NostrChatroomListDataSour
class NostrHomeFeedViewModel: FeedViewModel(NostrHomeDataSource) { class NostrHomeFeedViewModel: FeedViewModel(NostrHomeDataSource) {
override fun newListFromDataSource(): List<Note> { override fun newListFromDataSource(): List<Note> {
// Filter: no replies // Filter: no replies
return dataSource.feed().filter { it.isNewThread() }.take(100) return dataSource.feed().filter { it.isNewThread() }.take(1000)
} }
} }
class NostrHomeRepliesFeedViewModel: FeedViewModel(NostrHomeDataSource) { class NostrHomeRepliesFeedViewModel: FeedViewModel(NostrHomeDataSource) {
override fun newListFromDataSource(): List<Note> { override fun newListFromDataSource(): List<Note> {
// Filter: only replies // Filter: only replies
return dataSource.feed().filter {! it.isNewThread() }.take(100) return dataSource.feed().filter {! it.isNewThread() }.take(1000)
} }
} }
@@ -89,7 +89,8 @@ abstract class FeedViewModel(val dataSource: NostrDataSource<Note>): ViewModel()
val oldNotesState = feedContent.value val oldNotesState = feedContent.value
if (oldNotesState is FeedState.Loaded) { if (oldNotesState is FeedState.Loaded) {
if (notes != oldNotesState.feed) { // Using size as a proxy for has changed.
if (notes.size != oldNotesState.feed.value.size && notes.firstOrNull() != oldNotesState.feed.value.firstOrNull()) {
updateFeed(notes) updateFeed(notes)
} }
} else { } else {

View File

@@ -39,7 +39,8 @@ open class LnZapFeedViewModel(val dataSource: NostrDataSource<Pair<Note, Note>>)
val oldNotesState = feedContent.value val oldNotesState = feedContent.value
if (oldNotesState is LnZapFeedState.Loaded) { if (oldNotesState is LnZapFeedState.Loaded) {
if (notes != oldNotesState.feed) { // Using size as a proxy for has changed.
if (notes.size != oldNotesState.feed.value.size && notes.firstOrNull() != oldNotesState.feed.value.firstOrNull()) {
updateFeed(notes) updateFeed(notes)
} }
} else { } else {

View File

@@ -54,7 +54,8 @@ open class UserFeedViewModel(val dataSource: NostrDataSource<User>): ViewModel()
val oldNotesState = feedContent.value val oldNotesState = feedContent.value
if (oldNotesState is UserFeedState.Loaded) { if (oldNotesState is UserFeedState.Loaded) {
if (notes != oldNotesState.feed) { // Using size as a proxy for has changed.
if (notes.size != oldNotesState.feed.value.size && notes.firstOrNull() != oldNotesState.feed.value.firstOrNull()) {
updateFeed(notes) updateFeed(notes)
} }
} else { } else {