cleanup, potential fix endless loop
This commit is contained in:
+13
-27
@@ -40,7 +40,6 @@ import com.vitorpamplona.amethyst.ui.screen.NostrNIP90StatusFeedViewModel
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.RefresheableBox
|
import com.vitorpamplona.amethyst.ui.screen.RefresheableBox
|
||||||
import com.vitorpamplona.amethyst.ui.screen.RenderFeedState
|
import com.vitorpamplona.amethyst.ui.screen.RenderFeedState
|
||||||
import com.vitorpamplona.amethyst.ui.screen.SaveableFeedState
|
import com.vitorpamplona.amethyst.ui.screen.SaveableFeedState
|
||||||
import com.vitorpamplona.quartz.events.AppDefinitionEvent
|
|
||||||
import com.vitorpamplona.quartz.events.NIP90ContentDiscoveryRequestEvent
|
import com.vitorpamplona.quartz.events.NIP90ContentDiscoveryRequestEvent
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -90,7 +89,7 @@ fun NIP90ContentDiscoveryScreen(
|
|||||||
@Composable
|
@Composable
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
fun RenderNostrNIP90ContentDiscoveryScreen(
|
fun RenderNostrNIP90ContentDiscoveryScreen(
|
||||||
DVMID: String?,
|
dvmID: String?,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
resultFeedViewModel: NostrNIP90ContentDiscoveryFeedViewModel,
|
resultFeedViewModel: NostrNIP90ContentDiscoveryFeedViewModel,
|
||||||
@@ -99,51 +98,37 @@ fun RenderNostrNIP90ContentDiscoveryScreen(
|
|||||||
Column(Modifier.fillMaxHeight()) {
|
Column(Modifier.fillMaxHeight()) {
|
||||||
val pagerState = rememberPagerState { 2 }
|
val pagerState = rememberPagerState { 2 }
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
// TODO 1 Render a nice header with image and DVM name from the id
|
|
||||||
// TODO How do we get the event information here?
|
|
||||||
|
|
||||||
var dvminfo = "DVM " + DVMID
|
// TODO this now shows the first status update but there might be a better way
|
||||||
if (DVMID != null) {
|
|
||||||
val thread =
|
|
||||||
Thread {
|
|
||||||
try {
|
|
||||||
var note = LocalCache.checkGetOrCreateNote(DVMID)
|
|
||||||
if (note != null) {
|
|
||||||
dvminfo = ((note.event as AppDefinitionEvent).appMetaData()?.name ?: "DVM from note")
|
|
||||||
} else {
|
|
||||||
dvminfo = "DVM from not found"
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
thread.start()
|
|
||||||
thread.join()
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO this shows the status but there might be a better way
|
|
||||||
var dvmStatus = "DVM is processing..."
|
var dvmStatus = "DVM is processing..."
|
||||||
val thread =
|
val thread =
|
||||||
Thread {
|
Thread {
|
||||||
println(dvmStatus)
|
var count = 0
|
||||||
while (resultFeedViewModel.localFilter.feed().isEmpty()) {
|
while (resultFeedViewModel.localFilter.feed().isEmpty()) {
|
||||||
try {
|
try {
|
||||||
if (statusFeedViewModel.localFilter.feed().isNotEmpty()) {
|
if (statusFeedViewModel.localFilter.feed().isNotEmpty()) {
|
||||||
statusFeedViewModel.localFilter.feed()[0].event?.let { dvmStatus = it.content() }
|
statusFeedViewModel.localFilter.feed()[0].event?.let { dvmStatus = it.content() }
|
||||||
println(dvmStatus)
|
println(dvmStatus)
|
||||||
break
|
break
|
||||||
|
} else if (count > 1000) {
|
||||||
|
// Might not be the best way, but we want to avoid hanging in the loop forever
|
||||||
|
break
|
||||||
} else {
|
} else {
|
||||||
|
count++
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thread.start()
|
thread.start()
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
|
// TODO Maybe render a nice header with image and DVM name from the dvmID
|
||||||
|
// TODO How do we get the event information here?, LocalCache.checkGetOrCreateNote() returns note but event is empty
|
||||||
|
// TODO oterwise we have the NIP89 info in (note.event as AppDefinitionEvent).appMetaData()
|
||||||
|
// Text(text = dvminfo)
|
||||||
|
|
||||||
HorizontalPager(state = pagerState) {
|
HorizontalPager(state = pagerState) {
|
||||||
RefresheableBox(resultFeedViewModel, false) {
|
RefresheableBox(resultFeedViewModel, false) {
|
||||||
SaveableFeedState(resultFeedViewModel, null) { listState ->
|
SaveableFeedState(resultFeedViewModel, null) { listState ->
|
||||||
@@ -154,6 +139,7 @@ fun RenderNostrNIP90ContentDiscoveryScreen(
|
|||||||
nav,
|
nav,
|
||||||
null,
|
null,
|
||||||
onEmpty = {
|
onEmpty = {
|
||||||
|
// TODO Maybe also show some dvm image/text while waiting for the notes in this custom component
|
||||||
FeedEmptywithStatus(status = dvmStatus) {
|
FeedEmptywithStatus(status = dvmStatus) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user