load older notes in feed

This commit is contained in:
Believethehype
2024-07-07 22:01:16 +02:00
parent 511a7030b8
commit dcad12f836
3 changed files with 39 additions and 46 deletions

View File

@@ -84,7 +84,7 @@ object NostrUserProfileDataSource : AmethystNostrDataSource("UserProfileFeed") {
WikiNoteEvent.KIND, WikiNoteEvent.KIND,
), ),
authors = listOf(it.pubkeyHex), authors = listOf(it.pubkeyHex),
limit = 500, limit = 200,
), ),
) )
} }

View File

@@ -32,7 +32,7 @@ class UserProfileGalleryFeedFilter(
val user: User, val user: User,
val account: Account, val account: Account,
) : AdditiveFeedFilter<Note>() { ) : AdditiveFeedFilter<Note>() {
override fun feedKey(): String = account.userProfile().pubkeyHex + "-" + account.defaultStoriesFollowList.value override fun feedKey(): String = account.userProfile().pubkeyHex + "-" + "ProfileGallery"
override fun showHiddenKey(): Boolean = override fun showHiddenKey(): Boolean =
account.defaultStoriesFollowList.value == PeopleListEvent.blockListFor(account.userProfile().pubkeyHex) || account.defaultStoriesFollowList.value == PeopleListEvent.blockListFor(account.userProfile().pubkeyHex) ||
@@ -46,13 +46,17 @@ class UserProfileGalleryFeedFilter(
acceptableEvent(it, params, user) acceptableEvent(it, params, user)
} }
var sorted = sort(notes)
var finalnotes = setOf<Note>() var finalnotes = setOf<Note>()
for (item in notes) { for (item in sorted) {
item.associatedNote = (item.event as ProfileGalleryEntryEvent).event()?.let { LocalCache.getOrCreateNote(it) } val note = (item.event as ProfileGalleryEntryEvent).event()?.let { LocalCache.checkGetOrCreateNote(it) }
finalnotes = finalnotes + item if (note != null) {
note.associatedNote = item
finalnotes = finalnotes + note
}
} }
return sort(finalnotes) return finalnotes.toList()
} }
override fun applyFilter(collection: Set<Note>): Set<Note> = innerApplyFilter(collection) override fun applyFilter(collection: Set<Note>): Set<Note> = innerApplyFilter(collection)

View File

@@ -133,45 +133,27 @@ private fun GalleryFeedLoaded(
itemsIndexed(state.feed.value, key = { _, item -> item.idHex }) { _, item -> itemsIndexed(state.feed.value, key = { _, item -> item.idHex }) { _, item ->
val defaultModifier = remember { Modifier.fillMaxWidth().animateItemPlacement() } val defaultModifier = remember { Modifier.fillMaxWidth().animateItemPlacement() }
if (item.associatedNote != null) { Row(defaultModifier) {
if (item.associatedNote!!.event != null) { GalleryCardCompose(
if ((item.event as ProfileGalleryEntryEvent).hasUrl() && baseNote = item,
(item.event as ProfileGalleryEntryEvent).hasEvent() routeForLastRead = routeForLastRead,
) { modifier = Modifier,
val image = (item.event as ProfileGalleryEntryEvent).url() forceEventKind = forceEventKind,
accountViewModel = accountViewModel,
Row(defaultModifier) { nav = nav,
if (image != null) { )
GalleryCardCompose(
galleryNote = item,
image = image,
baseNote = item.associatedNote!!,
routeForLastRead = routeForLastRead,
modifier = Modifier,
forceEventKind = forceEventKind,
accountViewModel = accountViewModel,
nav = nav,
)
}
}
HorizontalDivider(
thickness = DividerThickness,
)
} else {
accountViewModel.delete(item)
}
}
} }
HorizontalDivider(
thickness = DividerThickness,
)
} }
} }
} }
@Composable @Composable
fun GalleryCardCompose( fun GalleryCardCompose(
galleryNote: Note,
baseNote: Note, baseNote: Note,
image: String,
routeForLastRead: String? = null, routeForLastRead: String? = null,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
parentBackgroundColor: MutableState<Color>? = null, parentBackgroundColor: MutableState<Color>? = null,
@@ -190,15 +172,22 @@ fun GalleryCardCompose(
nav = nav, nav = nav,
) { canPreview -> ) { canPreview ->
GalleryCard( if (baseNote.associatedNote != null) {
galleryNote = galleryNote, if (baseNote.associatedNote!!.event != null) {
baseNote = baseNote, val image = (baseNote.associatedNote!!.event as ProfileGalleryEntryEvent).url()
image = image, if (image != null) {
modifier = modifier, GalleryCard(
parentBackgroundColor = parentBackgroundColor, galleryNote = baseNote.associatedNote!!,
accountViewModel = accountViewModel, baseNote = baseNote,
nav = nav, image = image,
) modifier = modifier,
parentBackgroundColor = parentBackgroundColor,
accountViewModel = accountViewModel,
nav = nav,
)
}
}
}
} }
} }
} }