adjustments and cleanups
This commit is contained in:
@@ -106,7 +106,6 @@ open class NIP90ContentDiscoveryFilter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val sorted = sort(notes)
|
val sorted = sort(notes)
|
||||||
println("REQUEST: " + request)
|
|
||||||
if (sorted.isNotEmpty()) {
|
if (sorted.isNotEmpty()) {
|
||||||
var note = sorted.first()
|
var note = sorted.first()
|
||||||
|
|
||||||
|
|||||||
@@ -56,10 +56,8 @@ open class NIP90StatusFilter(
|
|||||||
// && it.event?.isTaggedUser(account.keyPair.pubKey.toHexKey()) == true // && params.match(noteEvent)
|
// && it.event?.isTaggedUser(account.keyPair.pubKey.toHexKey()) == true // && params.match(noteEvent)
|
||||||
}
|
}
|
||||||
if (status.isNotEmpty()) {
|
if (status.isNotEmpty()) {
|
||||||
println("Found status")
|
|
||||||
return listOf(status.first())
|
return listOf(status.first())
|
||||||
} else {
|
} else {
|
||||||
println("Empty status")
|
|
||||||
return listOf()
|
return listOf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,10 +86,8 @@ open class NIP90StatusFilter(
|
|||||||
// && it.event?.isTaggedUser(account.keyPair.pubKey.toHexKey()) == true // && params.match(noteEvent)
|
// && it.event?.isTaggedUser(account.keyPair.pubKey.toHexKey()) == true // && params.match(noteEvent)
|
||||||
}
|
}
|
||||||
if (status.isNotEmpty()) {
|
if (status.isNotEmpty()) {
|
||||||
println("Found status")
|
|
||||||
return setOf(status.first())
|
return setOf(status.first())
|
||||||
} else {
|
} else {
|
||||||
println("Empty status")
|
|
||||||
return setOf()
|
return setOf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -301,3 +301,19 @@ fun FeedEmpty(onRefresh: () -> Unit) {
|
|||||||
OutlinedButton(onClick = onRefresh) { Text(text = stringResource(R.string.refresh)) }
|
OutlinedButton(onClick = onRefresh) { Text(text = stringResource(R.string.refresh)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun FeedEmptywithStatus(
|
||||||
|
status: String,
|
||||||
|
onRefresh: () -> Unit,
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
Modifier.fillMaxSize(),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.Center,
|
||||||
|
) {
|
||||||
|
Text(status)
|
||||||
|
// Spacer(modifier = StdVertSpacer)
|
||||||
|
// OutlinedButton(onClick = onRefresh) { Text(text = stringResource(R.string.refresh)) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -288,7 +288,6 @@ class NostrNIP90ContentDiscoveryFeedViewModel(val account: Account, val dvmkey:
|
|||||||
FeedViewModel(NIP90ContentDiscoveryFilter(account, dvmkey, requestid)) {
|
FeedViewModel(NIP90ContentDiscoveryFilter(account, dvmkey, requestid)) {
|
||||||
class Factory(val account: Account, val dvmkey: String, val requestid: String) : ViewModelProvider.Factory {
|
class Factory(val account: Account, val dvmkey: String, val requestid: String) : ViewModelProvider.Factory {
|
||||||
override fun <NostrNIP90ContentDiscoveryFeedViewModel : ViewModel> create(modelClass: Class<NostrNIP90ContentDiscoveryFeedViewModel>): NostrNIP90ContentDiscoveryFeedViewModel {
|
override fun <NostrNIP90ContentDiscoveryFeedViewModel : ViewModel> create(modelClass: Class<NostrNIP90ContentDiscoveryFeedViewModel>): NostrNIP90ContentDiscoveryFeedViewModel {
|
||||||
println("FILTERREQUEST " + requestid)
|
|
||||||
return NostrNIP90ContentDiscoveryFeedViewModel(account, dvmkey, requestid) as NostrNIP90ContentDiscoveryFeedViewModel
|
return NostrNIP90ContentDiscoveryFeedViewModel(account, dvmkey, requestid) as NostrNIP90ContentDiscoveryFeedViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+53
-28
@@ -34,10 +34,13 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import com.vitorpamplona.amethyst.model.LocalCache
|
import com.vitorpamplona.amethyst.model.LocalCache
|
||||||
import com.vitorpamplona.amethyst.service.relays.Client
|
import com.vitorpamplona.amethyst.service.relays.Client
|
||||||
import com.vitorpamplona.amethyst.ui.screen.DVMStatusView
|
import com.vitorpamplona.amethyst.ui.screen.FeedEmptywithStatus
|
||||||
import com.vitorpamplona.amethyst.ui.screen.NostrNIP90ContentDiscoveryFeedViewModel
|
import com.vitorpamplona.amethyst.ui.screen.NostrNIP90ContentDiscoveryFeedViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.NostrNIP90StatusFeedViewModel
|
import com.vitorpamplona.amethyst.ui.screen.NostrNIP90StatusFeedViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.RefresheableFeedView
|
import com.vitorpamplona.amethyst.ui.screen.RefresheableBox
|
||||||
|
import com.vitorpamplona.amethyst.ui.screen.RenderFeedState
|
||||||
|
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
|
||||||
@@ -53,7 +56,6 @@ fun NIP90ContentDiscoveryScreen(
|
|||||||
NIP90ContentDiscoveryRequestEvent.create(DVMID, accountViewModel.account.signer) {
|
NIP90ContentDiscoveryRequestEvent.create(DVMID, accountViewModel.account.signer) {
|
||||||
Client.send(it)
|
Client.send(it)
|
||||||
requestID = it.id
|
requestID = it.id
|
||||||
println("REQUESTID: " + requestID)
|
|
||||||
LocalCache.justConsume(it, null)
|
LocalCache.justConsume(it, null)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -87,7 +89,7 @@ fun NIP90ContentDiscoveryScreen(
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@OptIn(ExperimentalFoundationApi::class)
|
@OptIn(ExperimentalFoundationApi::class)
|
||||||
private fun RenderNostrNIP90ContentDiscoveryScreen(
|
fun RenderNostrNIP90ContentDiscoveryScreen(
|
||||||
DVMID: String?,
|
DVMID: String?,
|
||||||
accountViewModel: AccountViewModel,
|
accountViewModel: AccountViewModel,
|
||||||
nav: (String) -> Unit,
|
nav: (String) -> Unit,
|
||||||
@@ -97,42 +99,65 @@ private fun RenderNostrNIP90ContentDiscoveryScreen(
|
|||||||
Column(Modifier.fillMaxHeight()) {
|
Column(Modifier.fillMaxHeight()) {
|
||||||
val pagerState = rememberPagerState { 2 }
|
val pagerState = rememberPagerState { 2 }
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
// TODO Render a nice header with image and DVM name from the id
|
// TODO 1 Render a nice header with image and DVM name from the id
|
||||||
|
// TODO How do we get the event information here?
|
||||||
/* if (DVMID != null) {
|
|
||||||
LoadNote(baseNoteHex = DVMID, accountViewModel = accountViewModel) {
|
|
||||||
if (it != null) {
|
|
||||||
NoteCompose(baseNote = it, quotesLeft = 0, accountViewModel = accountViewModel ) {
|
|
||||||
|
|
||||||
|
var dvminfo = "DVM " + DVMID
|
||||||
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (it != null) {
|
|
||||||
Text(text = (it.event as AppDefinitionEvent).content())
|
|
||||||
} else {
|
|
||||||
Text(text = "yo")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
// TODO only show this when the feed below hasnt loaded. I this possible?
|
thread.start()
|
||||||
// TODO render this more as a status label rather than a note
|
thread.join()
|
||||||
|
}
|
||||||
|
|
||||||
DVMStatusView(
|
// TODO 2 Get the latest event from the statusFeedViewModel
|
||||||
|
// TODO How do we extract the latest event.content (or event.status) from statusFeedViewModel
|
||||||
|
var dvmStatus = "DVM is processing..."
|
||||||
|
|
||||||
|
/* if (statusFeedViewModel.localFilter.feed().isNotEmpty()) {
|
||||||
|
statusFeedViewModel.localFilter.feed()[0].event?.let { Text(text = it.content()) }
|
||||||
|
} else {
|
||||||
|
Text(text = "Nah")
|
||||||
|
}
|
||||||
|
|
||||||
|
DVMStatusView(
|
||||||
statusFeedViewModel,
|
statusFeedViewModel,
|
||||||
null,
|
null,
|
||||||
enablePullRefresh = false,
|
enablePullRefresh = false,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel = accountViewModel,
|
||||||
nav = nav,
|
nav = nav,
|
||||||
)
|
)*/
|
||||||
|
|
||||||
|
// Text(text = dvminfo)
|
||||||
|
|
||||||
HorizontalPager(state = pagerState) {
|
HorizontalPager(state = pagerState) {
|
||||||
RefresheableFeedView(
|
RefresheableBox(resultFeedViewModel, false) {
|
||||||
resultFeedViewModel,
|
SaveableFeedState(resultFeedViewModel, null) { listState ->
|
||||||
null,
|
RenderFeedState(
|
||||||
enablePullRefresh = false,
|
resultFeedViewModel,
|
||||||
accountViewModel = accountViewModel,
|
accountViewModel,
|
||||||
nav = nav,
|
listState,
|
||||||
)
|
nav,
|
||||||
|
null,
|
||||||
|
onEmpty = {
|
||||||
|
FeedEmptywithStatus(status = dvmStatus) {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user