mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-25 12:01:45 +02:00
load older notes in feed
This commit is contained in:
@@ -84,7 +84,7 @@ object NostrUserProfileDataSource : AmethystNostrDataSource("UserProfileFeed") {
|
||||
WikiNoteEvent.KIND,
|
||||
),
|
||||
authors = listOf(it.pubkeyHex),
|
||||
limit = 500,
|
||||
limit = 200,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ class UserProfileGalleryFeedFilter(
|
||||
val user: User,
|
||||
val account: Account,
|
||||
) : AdditiveFeedFilter<Note>() {
|
||||
override fun feedKey(): String = account.userProfile().pubkeyHex + "-" + account.defaultStoriesFollowList.value
|
||||
override fun feedKey(): String = account.userProfile().pubkeyHex + "-" + "ProfileGallery"
|
||||
|
||||
override fun showHiddenKey(): Boolean =
|
||||
account.defaultStoriesFollowList.value == PeopleListEvent.blockListFor(account.userProfile().pubkeyHex) ||
|
||||
@@ -46,13 +46,17 @@ class UserProfileGalleryFeedFilter(
|
||||
acceptableEvent(it, params, user)
|
||||
}
|
||||
|
||||
var sorted = sort(notes)
|
||||
var finalnotes = setOf<Note>()
|
||||
for (item in notes) {
|
||||
item.associatedNote = (item.event as ProfileGalleryEntryEvent).event()?.let { LocalCache.getOrCreateNote(it) }
|
||||
finalnotes = finalnotes + item
|
||||
for (item in sorted) {
|
||||
val note = (item.event as ProfileGalleryEntryEvent).event()?.let { LocalCache.checkGetOrCreateNote(it) }
|
||||
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)
|
||||
|
@@ -133,45 +133,27 @@ private fun GalleryFeedLoaded(
|
||||
itemsIndexed(state.feed.value, key = { _, item -> item.idHex }) { _, item ->
|
||||
val defaultModifier = remember { Modifier.fillMaxWidth().animateItemPlacement() }
|
||||
|
||||
if (item.associatedNote != null) {
|
||||
if (item.associatedNote!!.event != null) {
|
||||
if ((item.event as ProfileGalleryEntryEvent).hasUrl() &&
|
||||
(item.event as ProfileGalleryEntryEvent).hasEvent()
|
||||
) {
|
||||
val image = (item.event as ProfileGalleryEntryEvent).url()
|
||||
|
||||
Row(defaultModifier) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
Row(defaultModifier) {
|
||||
GalleryCardCompose(
|
||||
baseNote = item,
|
||||
routeForLastRead = routeForLastRead,
|
||||
modifier = Modifier,
|
||||
forceEventKind = forceEventKind,
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
)
|
||||
}
|
||||
|
||||
HorizontalDivider(
|
||||
thickness = DividerThickness,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun GalleryCardCompose(
|
||||
galleryNote: Note,
|
||||
baseNote: Note,
|
||||
image: String,
|
||||
routeForLastRead: String? = null,
|
||||
modifier: Modifier = Modifier,
|
||||
parentBackgroundColor: MutableState<Color>? = null,
|
||||
@@ -190,15 +172,22 @@ fun GalleryCardCompose(
|
||||
nav = nav,
|
||||
) { canPreview ->
|
||||
|
||||
GalleryCard(
|
||||
galleryNote = galleryNote,
|
||||
baseNote = baseNote,
|
||||
image = image,
|
||||
modifier = modifier,
|
||||
parentBackgroundColor = parentBackgroundColor,
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
)
|
||||
if (baseNote.associatedNote != null) {
|
||||
if (baseNote.associatedNote!!.event != null) {
|
||||
val image = (baseNote.associatedNote!!.event as ProfileGalleryEntryEvent).url()
|
||||
if (image != null) {
|
||||
GalleryCard(
|
||||
galleryNote = baseNote.associatedNote!!,
|
||||
baseNote = baseNote,
|
||||
image = image,
|
||||
modifier = modifier,
|
||||
parentBackgroundColor = parentBackgroundColor,
|
||||
accountViewModel = accountViewModel,
|
||||
nav = nav,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user