Make naming clearer. Some refactoring. Add a function to retrieve the not corresponding to a follow set.

This commit is contained in:
KotlinGeekDev
2025-03-31 21:15:06 +01:00
parent 82f8fe96a1
commit bfa673ca2c
5 changed files with 8 additions and 7 deletions
@@ -3067,8 +3067,8 @@ class Account(
suspend fun getFollowSetNotes() =
withContext(Dispatchers.Default) {
val followSetNotes = LocalCache.getFollowSetsFor(userProfile())
userProfile().updateFollowSets(followSetNotes)
val followSetNotes = LocalCache.getFollowSetNotesFor(userProfile())
userProfile().updateFollowSetNotes(followSetNotes)
// userProfile().followSets = followSetNotes
println("Number of follow sets: ${followSetNotes.size}")
}
@@ -1961,7 +1961,7 @@ object LocalCache {
}
}
fun getFollowSetsFor(user: User): List<AddressableNote> {
fun getFollowSetNotesFor(user: User): List<AddressableNote> {
checkNotInMainThread()
return addressables
@@ -67,7 +67,7 @@ class User(
var latestMetadataRelay: String? = null
var latestContactList: ContactListEvent? = null
var latestBookmarkList: BookmarkListEvent? = null
var followSets: Set<AddressableNote> = setOf()
var followSetNotes: Set<AddressableNote> = setOf()
private set
var reports = mapOf<User, Set<Note>>()
@@ -168,8 +168,8 @@ class User(
flowSet?.relays?.invalidateData()
}
fun updateFollowSets(sets: List<AddressableNote>) {
followSets = followSets + sets
fun updateFollowSetNotes(setNotes: List<AddressableNote>) {
followSetNotes = followSetNotes + setNotes
}
fun addReport(note: Note) {
@@ -162,6 +162,7 @@ class NostrBookmarkPrivateFeedViewModel(
}
}
@Stable
class NostrUserFollowSetFeedViewModel(
val account: Account,
) : FollowSetFeedViewModel(FollowSetFeedFilter(account)) {
@@ -175,7 +175,7 @@ class AccountViewModel(
.map { followSetsState ->
checkNotInMainThread()
account.getFollowSetNotes()
followSetsState.user.followSets.map {
followSetsState.user.followSetNotes.map {
account.mapNoteToFollowSet(it)
}
}.flowOn(Dispatchers.Default)