initial desktop phase1 fixes
This commit is contained in:
@@ -74,11 +74,9 @@ import androidx.compose.ui.window.application
|
||||
import androidx.compose.ui.window.rememberWindowState
|
||||
import com.vitorpamplona.amethyst.commons.account.AccountManager
|
||||
import com.vitorpamplona.amethyst.commons.account.AccountState
|
||||
import com.vitorpamplona.amethyst.commons.navigation.AppScreen
|
||||
import com.vitorpamplona.amethyst.commons.ui.profile.ProfileInfoCard
|
||||
import com.vitorpamplona.amethyst.commons.ui.relay.RelayStatusCard
|
||||
import com.vitorpamplona.amethyst.commons.ui.screens.MessagesPlaceholder
|
||||
import com.vitorpamplona.amethyst.commons.ui.screens.NotificationsPlaceholder
|
||||
import com.vitorpamplona.amethyst.commons.ui.screens.SearchPlaceholder
|
||||
import com.vitorpamplona.amethyst.desktop.network.DesktopRelayConnectionManager
|
||||
import com.vitorpamplona.amethyst.desktop.ui.ComposeNoteDialog
|
||||
@@ -103,7 +101,9 @@ sealed class DesktopScreen {
|
||||
|
||||
data object MyProfile : DesktopScreen()
|
||||
|
||||
data class UserProfile(val pubKeyHex: String) : DesktopScreen()
|
||||
data class UserProfile(
|
||||
val pubKeyHex: String,
|
||||
) : DesktopScreen()
|
||||
|
||||
data object Settings : DesktopScreen()
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.vitorpamplona.amethyst.commons.account.AccountState
|
||||
import com.vitorpamplona.amethyst.commons.ui.components.LoadingState
|
||||
import com.vitorpamplona.amethyst.commons.ui.feed.FeedHeader
|
||||
import com.vitorpamplona.amethyst.commons.ui.note.NoteCard
|
||||
import com.vitorpamplona.amethyst.commons.util.toNoteDisplayData
|
||||
import com.vitorpamplona.amethyst.desktop.network.DesktopRelayConnectionManager
|
||||
@@ -197,30 +196,30 @@ fun FeedScreen(
|
||||
filters = filters,
|
||||
relays = configuredRelays,
|
||||
listener =
|
||||
object : IRequestListener {
|
||||
override fun onEvent(
|
||||
event: Event,
|
||||
isLive: Boolean,
|
||||
relay: NormalizedRelayUrl,
|
||||
forFilters: List<Filter>?,
|
||||
) {
|
||||
if (event.id !in seenIds) {
|
||||
seenIds.add(event.id)
|
||||
events.add(0, event)
|
||||
if (events.size > 200) {
|
||||
val removed = events.removeAt(events.size - 1)
|
||||
seenIds.remove(removed.id)
|
||||
object : IRequestListener {
|
||||
override fun onEvent(
|
||||
event: Event,
|
||||
isLive: Boolean,
|
||||
relay: NormalizedRelayUrl,
|
||||
forFilters: List<Filter>?,
|
||||
) {
|
||||
if (event.id !in seenIds) {
|
||||
seenIds.add(event.id)
|
||||
events.add(0, event)
|
||||
if (events.size > 200) {
|
||||
val removed = events.removeAt(events.size - 1)
|
||||
seenIds.remove(removed.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onEose(
|
||||
relay: NormalizedRelayUrl,
|
||||
forFilters: List<Filter>?,
|
||||
) {
|
||||
// End of stored events
|
||||
}
|
||||
},
|
||||
override fun onEose(
|
||||
relay: NormalizedRelayUrl,
|
||||
forFilters: List<Filter>?,
|
||||
) {
|
||||
// End of stored events
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
onDispose {
|
||||
|
||||
@@ -45,7 +45,6 @@ import com.vitorpamplona.amethyst.commons.icons.Repost
|
||||
import com.vitorpamplona.amethyst.desktop.network.DesktopRelayConnectionManager
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.hints.EventHintBundle
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||
import com.vitorpamplona.quartz.nip18Reposts.GenericRepostEvent
|
||||
import com.vitorpamplona.quartz.nip18Reposts.RepostEvent
|
||||
import com.vitorpamplona.quartz.nip25Reactions.ReactionEvent
|
||||
|
||||
+26
-9
@@ -53,7 +53,6 @@ import com.vitorpamplona.amethyst.commons.icons.Repost
|
||||
import com.vitorpamplona.amethyst.commons.icons.Zap
|
||||
import com.vitorpamplona.amethyst.commons.ui.components.LoadingState
|
||||
import com.vitorpamplona.amethyst.commons.ui.feed.FeedHeader
|
||||
import com.vitorpamplona.amethyst.commons.util.toNoteDisplayData
|
||||
import com.vitorpamplona.amethyst.commons.util.toTimeAgo
|
||||
import com.vitorpamplona.amethyst.desktop.network.DesktopRelayConnectionManager
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
@@ -75,17 +74,32 @@ sealed class NotificationItem(
|
||||
open val event: Event,
|
||||
open val timestamp: Long,
|
||||
) {
|
||||
data class Mention(override val event: Event, override val timestamp: Long) : NotificationItem(event, timestamp)
|
||||
data class Mention(
|
||||
override val event: Event,
|
||||
override val timestamp: Long,
|
||||
) : NotificationItem(event, timestamp)
|
||||
|
||||
data class Reply(override val event: Event, override val timestamp: Long) : NotificationItem(event, timestamp)
|
||||
data class Reply(
|
||||
override val event: Event,
|
||||
override val timestamp: Long,
|
||||
) : NotificationItem(event, timestamp)
|
||||
|
||||
data class Reaction(override val event: Event, override val timestamp: Long, val content: String) :
|
||||
NotificationItem(event, timestamp)
|
||||
data class Reaction(
|
||||
override val event: Event,
|
||||
override val timestamp: Long,
|
||||
val content: String,
|
||||
) : NotificationItem(event, timestamp)
|
||||
|
||||
data class Repost(override val event: Event, override val timestamp: Long) : NotificationItem(event, timestamp)
|
||||
data class Repost(
|
||||
override val event: Event,
|
||||
override val timestamp: Long,
|
||||
) : NotificationItem(event, timestamp)
|
||||
|
||||
data class Zap(override val event: Event, override val timestamp: Long, val amount: Long?) :
|
||||
NotificationItem(event, timestamp)
|
||||
data class Zap(
|
||||
override val event: Event,
|
||||
override val timestamp: Long,
|
||||
val amount: Long?,
|
||||
) : NotificationItem(event, timestamp)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -245,7 +259,10 @@ fun NotificationCard(notification: NotificationItem) {
|
||||
|
||||
val authorDisplay =
|
||||
try {
|
||||
notification.event.pubKey.hexToByteArrayOrNull()?.toNpub()?.take(20) ?: notification.event.pubKey.take(20)
|
||||
notification.event.pubKey
|
||||
.hexToByteArrayOrNull()
|
||||
?.toNpub()
|
||||
?.take(20) ?: notification.event.pubKey.take(20)
|
||||
} catch (e: Exception) {
|
||||
notification.event.pubKey.take(20)
|
||||
}
|
||||
|
||||
+8
-8
@@ -65,12 +65,11 @@ import com.vitorpamplona.amethyst.commons.account.AccountState
|
||||
import com.vitorpamplona.amethyst.commons.ui.components.LoadingState
|
||||
import com.vitorpamplona.amethyst.desktop.network.DesktopRelayConnectionManager
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.core.hexToByteArrayOrNull
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.client.reqs.IRequestListener
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
||||
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
|
||||
import com.vitorpamplona.quartz.nip01Core.core.hexToByteArrayOrNull
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.isTaggedUser
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.pTag
|
||||
import com.vitorpamplona.quartz.nip02FollowList.ContactListEvent
|
||||
import com.vitorpamplona.quartz.nip02FollowList.ReadWrite
|
||||
import com.vitorpamplona.quartz.nip02FollowList.tags.ContactTag
|
||||
@@ -250,13 +249,14 @@ fun UserProfileScreen(
|
||||
)
|
||||
|
||||
// Set timeout for loading state
|
||||
val timeoutJob = kotlinx.coroutines.CoroutineScope(kotlinx.coroutines.Dispatchers.Default).launch {
|
||||
kotlinx.coroutines.delay(10000) // 10 second timeout
|
||||
if (postsLoading) {
|
||||
postsError = "Request timed out. Check relay connections."
|
||||
postsLoading = false
|
||||
val timeoutJob =
|
||||
kotlinx.coroutines.CoroutineScope(kotlinx.coroutines.Dispatchers.Default).launch {
|
||||
kotlinx.coroutines.delay(10000) // 10 second timeout
|
||||
if (postsLoading) {
|
||||
postsError = "Request timed out. Check relay connections."
|
||||
postsLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onDispose {
|
||||
timeoutJob.cancel()
|
||||
|
||||
Reference in New Issue
Block a user