Make naming clearer. Some refactoring. Add a function to retrieve the not corresponding to a follow set.
This commit is contained in:
@@ -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)) {
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
+13
-3
@@ -22,16 +22,18 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.lists
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.vitorpamplona.amethyst.model.Account
|
||||
import com.vitorpamplona.amethyst.model.AddressableNote
|
||||
import com.vitorpamplona.amethyst.model.LocalCache
|
||||
import com.vitorpamplona.amethyst.service.checkNotInMainThread
|
||||
import com.vitorpamplona.amethyst.ui.dal.FeedFilter
|
||||
import com.vitorpamplona.amethyst.ui.feeds.InvalidatableContent
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.equalImmutableLists
|
||||
import com.vitorpamplona.ammolite.relays.BundledUpdate
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -41,8 +43,7 @@ import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Stable
|
||||
open class FollowSetFeedViewModel(
|
||||
abstract class FollowSetFeedViewModel(
|
||||
val dataSource: FeedFilter<FollowSet>,
|
||||
) : ViewModel(),
|
||||
InvalidatableContent {
|
||||
@@ -55,6 +56,15 @@ open class FollowSetFeedViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun getFollowSetAddressable(
|
||||
addressValue: String,
|
||||
account: Account,
|
||||
): AddressableNote? {
|
||||
checkNotInMainThread()
|
||||
val potentialNote = LocalCache.getAddressableNoteIfExists(Address.parse(addressValue)!!)
|
||||
return potentialNote
|
||||
}
|
||||
|
||||
override val isRefreshing: MutableState<Boolean> = mutableStateOf(false)
|
||||
|
||||
private fun refreshSuspended() {
|
||||
|
||||
+4
-2
@@ -68,6 +68,7 @@ import com.vitorpamplona.amethyst.ui.theme.StdHorzSpacer
|
||||
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||
import com.vitorpamplona.amethyst.ui.theme.ZeroPadding
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.UUID
|
||||
|
||||
@Composable
|
||||
fun FollowSetsActionMenu(
|
||||
@@ -174,14 +175,15 @@ private fun DropDownMenuHeader(
|
||||
fun generateFollowLists(): List<FollowSet> =
|
||||
List(10) { index: Int ->
|
||||
FollowSet(
|
||||
identifierTag = UUID.randomUUID().toString(),
|
||||
title = "List No $index",
|
||||
description = null,
|
||||
visibility =
|
||||
when {
|
||||
index % 2 == 0 -> ListVisibility.Private
|
||||
index in listOf(3, 7, 9) -> ListVisibility.Mixed
|
||||
else -> ListVisibility.Public
|
||||
},
|
||||
title = "List No $index",
|
||||
description = null,
|
||||
profileList = emptySet(),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user