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() =
|
suspend fun getFollowSetNotes() =
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
val followSetNotes = LocalCache.getFollowSetsFor(userProfile())
|
val followSetNotes = LocalCache.getFollowSetNotesFor(userProfile())
|
||||||
userProfile().updateFollowSets(followSetNotes)
|
userProfile().updateFollowSetNotes(followSetNotes)
|
||||||
// userProfile().followSets = followSetNotes
|
// userProfile().followSets = followSetNotes
|
||||||
println("Number of follow sets: ${followSetNotes.size}")
|
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()
|
checkNotInMainThread()
|
||||||
|
|
||||||
return addressables
|
return addressables
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class User(
|
|||||||
var latestMetadataRelay: String? = null
|
var latestMetadataRelay: String? = null
|
||||||
var latestContactList: ContactListEvent? = null
|
var latestContactList: ContactListEvent? = null
|
||||||
var latestBookmarkList: BookmarkListEvent? = null
|
var latestBookmarkList: BookmarkListEvent? = null
|
||||||
var followSets: Set<AddressableNote> = setOf()
|
var followSetNotes: Set<AddressableNote> = setOf()
|
||||||
private set
|
private set
|
||||||
|
|
||||||
var reports = mapOf<User, Set<Note>>()
|
var reports = mapOf<User, Set<Note>>()
|
||||||
@@ -168,8 +168,8 @@ class User(
|
|||||||
flowSet?.relays?.invalidateData()
|
flowSet?.relays?.invalidateData()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateFollowSets(sets: List<AddressableNote>) {
|
fun updateFollowSetNotes(setNotes: List<AddressableNote>) {
|
||||||
followSets = followSets + sets
|
followSetNotes = followSetNotes + setNotes
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addReport(note: Note) {
|
fun addReport(note: Note) {
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ class NostrBookmarkPrivateFeedViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Stable
|
||||||
class NostrUserFollowSetFeedViewModel(
|
class NostrUserFollowSetFeedViewModel(
|
||||||
val account: Account,
|
val account: Account,
|
||||||
) : FollowSetFeedViewModel(FollowSetFeedFilter(account)) {
|
) : FollowSetFeedViewModel(FollowSetFeedFilter(account)) {
|
||||||
|
|||||||
+1
-1
@@ -175,7 +175,7 @@ class AccountViewModel(
|
|||||||
.map { followSetsState ->
|
.map { followSetsState ->
|
||||||
checkNotInMainThread()
|
checkNotInMainThread()
|
||||||
account.getFollowSetNotes()
|
account.getFollowSetNotes()
|
||||||
followSetsState.user.followSets.map {
|
followSetsState.user.followSetNotes.map {
|
||||||
account.mapNoteToFollowSet(it)
|
account.mapNoteToFollowSet(it)
|
||||||
}
|
}
|
||||||
}.flowOn(Dispatchers.Default)
|
}.flowOn(Dispatchers.Default)
|
||||||
|
|||||||
+13
-3
@@ -22,16 +22,18 @@ package com.vitorpamplona.amethyst.ui.screen.loggedIn.lists
|
|||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.compose.runtime.MutableState
|
import androidx.compose.runtime.MutableState
|
||||||
import androidx.compose.runtime.Stable
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
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.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.service.checkNotInMainThread
|
import com.vitorpamplona.amethyst.service.checkNotInMainThread
|
||||||
import com.vitorpamplona.amethyst.ui.dal.FeedFilter
|
import com.vitorpamplona.amethyst.ui.dal.FeedFilter
|
||||||
import com.vitorpamplona.amethyst.ui.feeds.InvalidatableContent
|
import com.vitorpamplona.amethyst.ui.feeds.InvalidatableContent
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.equalImmutableLists
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.notifications.equalImmutableLists
|
||||||
import com.vitorpamplona.ammolite.relays.BundledUpdate
|
import com.vitorpamplona.ammolite.relays.BundledUpdate
|
||||||
|
import com.vitorpamplona.quartz.nip01Core.tags.addressables.Address
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -41,8 +43,7 @@ import kotlinx.coroutines.flow.asStateFlow
|
|||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@Stable
|
abstract class FollowSetFeedViewModel(
|
||||||
open class FollowSetFeedViewModel(
|
|
||||||
val dataSource: FeedFilter<FollowSet>,
|
val dataSource: FeedFilter<FollowSet>,
|
||||||
) : ViewModel(),
|
) : ViewModel(),
|
||||||
InvalidatableContent {
|
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)
|
override val isRefreshing: MutableState<Boolean> = mutableStateOf(false)
|
||||||
|
|
||||||
private fun refreshSuspended() {
|
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.StdVertSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.ZeroPadding
|
import com.vitorpamplona.amethyst.ui.theme.ZeroPadding
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun FollowSetsActionMenu(
|
fun FollowSetsActionMenu(
|
||||||
@@ -174,14 +175,15 @@ private fun DropDownMenuHeader(
|
|||||||
fun generateFollowLists(): List<FollowSet> =
|
fun generateFollowLists(): List<FollowSet> =
|
||||||
List(10) { index: Int ->
|
List(10) { index: Int ->
|
||||||
FollowSet(
|
FollowSet(
|
||||||
|
identifierTag = UUID.randomUUID().toString(),
|
||||||
|
title = "List No $index",
|
||||||
|
description = null,
|
||||||
visibility =
|
visibility =
|
||||||
when {
|
when {
|
||||||
index % 2 == 0 -> ListVisibility.Private
|
index % 2 == 0 -> ListVisibility.Private
|
||||||
index in listOf(3, 7, 9) -> ListVisibility.Mixed
|
index in listOf(3, 7, 9) -> ListVisibility.Mixed
|
||||||
else -> ListVisibility.Public
|
else -> ListVisibility.Public
|
||||||
},
|
},
|
||||||
title = "List No $index",
|
|
||||||
description = null,
|
|
||||||
profileList = emptySet(),
|
profileList = emptySet(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user