adjustments and cleanups

pull/856/head
Believethehype 2024-05-15 15:11:36 +02:00
rodzic 142aca40ce
commit 420323bcb0
5 zmienionych plików z 69 dodań i 34 usunięć

Wyświetl plik

@ -106,7 +106,6 @@ open class NIP90ContentDiscoveryFilter(
}
val sorted = sort(notes)
println("REQUEST: " + request)
if (sorted.isNotEmpty()) {
var note = sorted.first()

Wyświetl plik

@ -56,10 +56,8 @@ open class NIP90StatusFilter(
// && it.event?.isTaggedUser(account.keyPair.pubKey.toHexKey()) == true // && params.match(noteEvent)
}
if (status.isNotEmpty()) {
println("Found status")
return listOf(status.first())
} else {
println("Empty status")
return listOf()
}
}
@ -88,10 +86,8 @@ open class NIP90StatusFilter(
// && it.event?.isTaggedUser(account.keyPair.pubKey.toHexKey()) == true // && params.match(noteEvent)
}
if (status.isNotEmpty()) {
println("Found status")
return setOf(status.first())
} else {
println("Empty status")
return setOf()
}
}

Wyświetl plik

@ -301,3 +301,19 @@ fun FeedEmpty(onRefresh: () -> Unit) {
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)) }
}
}

Wyświetl plik

@ -288,7 +288,6 @@ class NostrNIP90ContentDiscoveryFeedViewModel(val account: Account, val dvmkey:
FeedViewModel(NIP90ContentDiscoveryFilter(account, dvmkey, requestid)) {
class Factory(val account: Account, val dvmkey: String, val requestid: String) : ViewModelProvider.Factory {
override fun <NostrNIP90ContentDiscoveryFeedViewModel : ViewModel> create(modelClass: Class<NostrNIP90ContentDiscoveryFeedViewModel>): NostrNIP90ContentDiscoveryFeedViewModel {
println("FILTERREQUEST " + requestid)
return NostrNIP90ContentDiscoveryFeedViewModel(account, dvmkey, requestid) as NostrNIP90ContentDiscoveryFeedViewModel
}
}

Wyświetl plik

@ -34,10 +34,13 @@ import androidx.compose.ui.Modifier
import androidx.lifecycle.viewmodel.compose.viewModel
import com.vitorpamplona.amethyst.model.LocalCache
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.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
@Composable
@ -53,7 +56,6 @@ fun NIP90ContentDiscoveryScreen(
NIP90ContentDiscoveryRequestEvent.create(DVMID, accountViewModel.account.signer) {
Client.send(it)
requestID = it.id
println("REQUESTID: " + requestID)
LocalCache.justConsume(it, null)
}
} catch (e: Exception) {
@ -87,7 +89,7 @@ fun NIP90ContentDiscoveryScreen(
@Composable
@OptIn(ExperimentalFoundationApi::class)
private fun RenderNostrNIP90ContentDiscoveryScreen(
fun RenderNostrNIP90ContentDiscoveryScreen(
DVMID: String?,
accountViewModel: AccountViewModel,
nav: (String) -> Unit,
@ -97,42 +99,65 @@ private fun RenderNostrNIP90ContentDiscoveryScreen(
Column(Modifier.fillMaxHeight()) {
val pagerState = rememberPagerState { 2 }
val coroutineScope = rememberCoroutineScope()
// TODO Render a nice header with image and DVM name from the id
/* if (DVMID != null) {
LoadNote(baseNoteHex = DVMID, accountViewModel = accountViewModel) {
if (it != null) {
NoteCompose(baseNote = it, quotesLeft = 0, accountViewModel = accountViewModel ) {
// 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
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?
// TODO render this more as a status label rather than a note
thread.start()
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,
null,
enablePullRefresh = false,
accountViewModel = accountViewModel,
nav = nav,
)
)*/
// Text(text = dvminfo)
HorizontalPager(state = pagerState) {
RefresheableFeedView(
resultFeedViewModel,
null,
enablePullRefresh = false,
accountViewModel = accountViewModel,
nav = nav,
)
RefresheableBox(resultFeedViewModel, false) {
SaveableFeedState(resultFeedViewModel, null) { listState ->
RenderFeedState(
resultFeedViewModel,
accountViewModel,
listState,
nav,
null,
onEmpty = {
FeedEmptywithStatus(status = dvmStatus) {
}
},
)
}
}
}
}
}