mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-28 09:56:45 +02:00
load older notes in feed
This commit is contained in:
@@ -84,7 +84,7 @@ object NostrUserProfileDataSource : AmethystNostrDataSource("UserProfileFeed") {
|
|||||||
WikiNoteEvent.KIND,
|
WikiNoteEvent.KIND,
|
||||||
),
|
),
|
||||||
authors = listOf(it.pubkeyHex),
|
authors = listOf(it.pubkeyHex),
|
||||||
limit = 500,
|
limit = 200,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
|
@@ -133,19 +133,9 @@ 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) {
|
|
||||||
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) {
|
Row(defaultModifier) {
|
||||||
if (image != null) {
|
|
||||||
GalleryCardCompose(
|
GalleryCardCompose(
|
||||||
galleryNote = item,
|
baseNote = item,
|
||||||
image = image,
|
|
||||||
baseNote = item.associatedNote!!,
|
|
||||||
routeForLastRead = routeForLastRead,
|
routeForLastRead = routeForLastRead,
|
||||||
modifier = Modifier,
|
modifier = Modifier,
|
||||||
forceEventKind = forceEventKind,
|
forceEventKind = forceEventKind,
|
||||||
@@ -153,25 +143,17 @@ private fun GalleryFeedLoaded(
|
|||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
HorizontalDivider(
|
HorizontalDivider(
|
||||||
thickness = DividerThickness,
|
thickness = DividerThickness,
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
accountViewModel.delete(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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,8 +172,12 @@ fun GalleryCardCompose(
|
|||||||
nav = nav,
|
nav = nav,
|
||||||
) { canPreview ->
|
) { canPreview ->
|
||||||
|
|
||||||
|
if (baseNote.associatedNote != null) {
|
||||||
|
if (baseNote.associatedNote!!.event != null) {
|
||||||
|
val image = (baseNote.associatedNote!!.event as ProfileGalleryEntryEvent).url()
|
||||||
|
if (image != null) {
|
||||||
GalleryCard(
|
GalleryCard(
|
||||||
galleryNote = galleryNote,
|
galleryNote = baseNote.associatedNote!!,
|
||||||
baseNote = baseNote,
|
baseNote = baseNote,
|
||||||
image = image,
|
image = image,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
@@ -201,6 +187,9 @@ fun GalleryCardCompose(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
Reference in New Issue
Block a user