Adjusts Outbox filter as soon as a new NIP-65 relay list shows up
This commit is contained in:
@@ -449,11 +449,10 @@ class Account(
|
||||
val liveKind3Follows = liveKind3FollowsFlow.stateIn(scope, SharingStarted.Eagerly, LiveFollowLists(usersPlusMe = setOf(keyPair.pubKeyHex)))
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
private val liveHomeList: Flow<ListNameNotePair> by lazy {
|
||||
private val liveHomeList: Flow<ListNameNotePair> =
|
||||
defaultHomeFollowList.flatMapLatest { listName ->
|
||||
loadPeopleListFlowFromListName(listName)
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
fun loadPeopleListFlowFromListName(listName: String): Flow<ListNameNotePair> =
|
||||
@@ -490,7 +489,7 @@ class Account(
|
||||
}
|
||||
|
||||
val liveHomeFollowListFlow: Flow<LiveFollowLists?> by lazy {
|
||||
combinePeopleListFlows(liveKind3FollowsFlow, liveHomeList)
|
||||
combinePeopleListFlows(liveKind3Follows, liveHomeList)
|
||||
}
|
||||
|
||||
val liveHomeFollowLists: StateFlow<LiveFollowLists?> by lazy {
|
||||
@@ -544,8 +543,7 @@ class Account(
|
||||
fun authorsPerRelay(
|
||||
followsNIP65RelayLists: Array<NoteState>,
|
||||
defaultRelayList: List<String>,
|
||||
): Map<String, List<HexKey>> {
|
||||
val test =
|
||||
): Map<String, List<HexKey>> =
|
||||
assembleAuthorsPerWriteRelay(
|
||||
followsNIP65RelayLists
|
||||
.mapNotNull
|
||||
@@ -567,9 +565,6 @@ class Account(
|
||||
hasOnionConnection = proxy != null,
|
||||
)
|
||||
|
||||
return test
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
val liveHomeFollowListAdvertizedRelayListFlow: Flow<Array<NoteState>?> =
|
||||
liveHomeFollowLists
|
||||
|
||||
@@ -55,6 +55,7 @@ object NostrHomeDataSource : AmethystNostrDataSource("HomeFeed") {
|
||||
val latestEOSEs = EOSEAccount()
|
||||
|
||||
var job: Job? = null
|
||||
var job2: Job? = null
|
||||
|
||||
override fun start() {
|
||||
job?.cancel()
|
||||
@@ -68,12 +69,25 @@ object NostrHomeDataSource : AmethystNostrDataSource("HomeFeed") {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
job2?.cancel()
|
||||
job2 =
|
||||
scope.launch(Dispatchers.IO) {
|
||||
// creates cache on main
|
||||
withContext(Dispatchers.Main) { account.userProfile().live() }
|
||||
account.liveHomeListAuthorsPerRelay.collect {
|
||||
if (this@NostrHomeDataSource::account.isInitialized) {
|
||||
invalidateFilters()
|
||||
}
|
||||
}
|
||||
}
|
||||
super.start()
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
super.stop()
|
||||
job?.cancel()
|
||||
job2?.cancel()
|
||||
}
|
||||
|
||||
fun createFollowAccountsFilter(): TypedFilter {
|
||||
|
||||
Reference in New Issue
Block a user