Fixes displaying an old result when coming back to a DVM screen
This commit is contained in:
@@ -236,8 +236,8 @@ class NostrBookmarkPrivateFeedViewModel(
|
|||||||
@Stable
|
@Stable
|
||||||
class NostrNIP90ContentDiscoveryFeedViewModel(
|
class NostrNIP90ContentDiscoveryFeedViewModel(
|
||||||
val account: Account,
|
val account: Account,
|
||||||
val dvmkey: String,
|
dvmkey: String,
|
||||||
val requestid: String,
|
requestid: String,
|
||||||
) : FeedViewModel(NIP90ContentDiscoveryResponseFilter(account, dvmkey, requestid)) {
|
) : FeedViewModel(NIP90ContentDiscoveryResponseFilter(account, dvmkey, requestid)) {
|
||||||
class Factory(
|
class Factory(
|
||||||
val account: Account,
|
val account: Account,
|
||||||
|
|||||||
+6
-2
@@ -204,11 +204,13 @@ fun ObserverContentDiscoveryResponse(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val latestResponse by resultFlow.collectAsStateWithLifecycle()
|
val latestResponse by resultFlow.collectAsStateWithLifecycle()
|
||||||
|
val myResponse = latestResponse
|
||||||
|
|
||||||
if (latestResponse != null) {
|
if (myResponse != null) {
|
||||||
PrepareViewContentDiscoveryModels(
|
PrepareViewContentDiscoveryModels(
|
||||||
noteAuthor,
|
noteAuthor,
|
||||||
dvmRequestId.idHex,
|
dvmRequestId.idHex,
|
||||||
|
myResponse,
|
||||||
onRefresh,
|
onRefresh,
|
||||||
accountViewModel,
|
accountViewModel,
|
||||||
nav,
|
nav,
|
||||||
@@ -236,6 +238,7 @@ fun ObserverDvmStatusResponse(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val latestStatus by statusFlow.collectAsStateWithLifecycle()
|
val latestStatus by statusFlow.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
// TODO: Make a good splash screen with loading animation for this DVM.
|
// TODO: Make a good splash screen with loading animation for this DVM.
|
||||||
if (latestStatus != null) {
|
if (latestStatus != null) {
|
||||||
// TODO: Make a good splash screen with loading animation for this DVM.
|
// TODO: Make a good splash screen with loading animation for this DVM.
|
||||||
@@ -252,6 +255,7 @@ fun ObserverDvmStatusResponse(
|
|||||||
fun PrepareViewContentDiscoveryModels(
|
fun PrepareViewContentDiscoveryModels(
|
||||||
dvm: User,
|
dvm: User,
|
||||||
dvmRequestId: String,
|
dvmRequestId: String,
|
||||||
|
latestResponse: NIP90ContentDiscoveryResponseEvent,
|
||||||
onRefresh: () -> Unit,
|
onRefresh: () -> Unit,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: INav,
|
nav: INav,
|
||||||
@@ -262,7 +266,7 @@ fun PrepareViewContentDiscoveryModels(
|
|||||||
factory = NostrNIP90ContentDiscoveryFeedViewModel.Factory(accountViewModel.account, dvmkey = dvm.pubkeyHex, requestid = dvmRequestId),
|
factory = NostrNIP90ContentDiscoveryFeedViewModel.Factory(accountViewModel.account, dvmkey = dvm.pubkeyHex, requestid = dvmRequestId),
|
||||||
)
|
)
|
||||||
|
|
||||||
LaunchedEffect(key1 = dvmRequestId) {
|
LaunchedEffect(key1 = dvmRequestId, latestResponse.id) {
|
||||||
resultFeedViewModel.invalidateData()
|
resultFeedViewModel.invalidateData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class BiMaxOfCollector<K, V>(
|
|||||||
v: V,
|
v: V,
|
||||||
) {
|
) {
|
||||||
if (filter.filter(k, v)) {
|
if (filter.filter(k, v)) {
|
||||||
if (maxK == null || comparator.compare(v, maxV) > 1) {
|
if (maxK == null || comparator.compare(v, maxV) > 0) {
|
||||||
maxK = k
|
maxK = k
|
||||||
maxV = v
|
maxV = v
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user