mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-09 08:04:45 +00:00
Fixes some of the live stream flags when the event doesn't update.
This commit is contained in:
@@ -139,7 +139,7 @@ fun RenderLiveActivityEventInner(
|
||||
val subject = remember(eventUpdates) { noteEvent.title() }
|
||||
val content = remember(eventUpdates) { noteEvent.summary() }
|
||||
val participants = remember(eventUpdates) { noteEvent.participants() }
|
||||
val status = remember(eventUpdates) { noteEvent.statusEnum() }
|
||||
val status = remember(eventUpdates) { noteEvent.status() }
|
||||
val starts = remember(eventUpdates) { noteEvent.starts() }
|
||||
|
||||
Row(
|
||||
|
||||
+10
-5
@@ -35,6 +35,7 @@ import com.vitorpamplona.amethyst.R
|
||||
import com.vitorpamplona.amethyst.ui.stringRes
|
||||
import com.vitorpamplona.amethyst.ui.theme.SmallBorder
|
||||
import com.vitorpamplona.amethyst.ui.theme.liveStreamTag
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
@@ -92,11 +93,15 @@ fun OfflineFlag() {
|
||||
fun ScheduledFlag(starts: Long?) {
|
||||
val startsIn =
|
||||
starts?.let {
|
||||
SimpleDateFormat
|
||||
.getDateTimeInstance(
|
||||
DateFormat.SHORT,
|
||||
DateFormat.SHORT,
|
||||
).format(Date(starts * 1000))
|
||||
if (it > TimeUtils.now()) {
|
||||
SimpleDateFormat
|
||||
.getDateTimeInstance(
|
||||
DateFormat.SHORT,
|
||||
DateFormat.SHORT,
|
||||
).format(Date(starts * 1000))
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
Text(
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ open class DiscoverLiveFeedFilter(
|
||||
return collection
|
||||
.sortedWith(
|
||||
compareBy(
|
||||
{ convertStatusToOrder((it.event as? LiveActivitiesEvent)?.statusEnum()) },
|
||||
{ convertStatusToOrder((it.event as? LiveActivitiesEvent)?.status()) },
|
||||
{ participantCounts[it] },
|
||||
{ allParticipants[it] },
|
||||
{ (it.event as? LiveActivitiesEvent)?.starts() ?: it.createdAt() },
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ fun RenderLiveActivityThumb(
|
||||
subject = noteEvent?.title()?.ifBlank { null },
|
||||
content = noteEvent?.summary(),
|
||||
participants = noteEvent?.participants()?.toImmutableList() ?: persistentListOf(),
|
||||
status = noteEvent?.statusEnum(),
|
||||
status = noteEvent?.status(),
|
||||
starts = noteEvent?.starts(),
|
||||
)
|
||||
}
|
||||
|
||||
+13
-18
@@ -29,14 +29,8 @@ import com.vitorpamplona.quartz.nip01Core.hints.EventHintProvider
|
||||
import com.vitorpamplona.quartz.nip01Core.hints.PubKeyHintProvider
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag.Companion.parseAsHint
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.events.ETag
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.events.ETag.Companion.parseAsHint
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.PTag.Companion.parseAsHint
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.PTag.Companion.parseKey
|
||||
import com.vitorpamplona.quartz.nip18Reposts.quotes.QTag
|
||||
import com.vitorpamplona.quartz.nip18Reposts.quotes.QTag.Companion.parseAddressAsHint
|
||||
import com.vitorpamplona.quartz.nip18Reposts.quotes.QTag.Companion.parseEventAsHint
|
||||
import com.vitorpamplona.quartz.nip23LongContent.tags.ImageTag
|
||||
import com.vitorpamplona.quartz.nip23LongContent.tags.SummaryTag
|
||||
import com.vitorpamplona.quartz.nip23LongContent.tags.TitleTag
|
||||
@@ -88,11 +82,9 @@ class LiveActivitiesEvent(
|
||||
|
||||
fun ends() = tags.firstNotNullOfOrNull(EndsTag::parse)
|
||||
|
||||
fun status() = checkStatus(tags.firstNotNullOfOrNull(StatusTag::parse))
|
||||
fun status() = checkStatus(tags.firstNotNullOfOrNull(StatusTag::parseEnum))
|
||||
|
||||
fun statusEnum() = checkStatusEnum(tags.firstNotNullOfOrNull(StatusTag::parseEnum))
|
||||
|
||||
fun isLive() = statusEnum() == StatusTag.STATUS.LIVE
|
||||
fun isLive() = status() == StatusTag.STATUS.LIVE
|
||||
|
||||
fun currentParticipants() = tags.firstNotNullOfOrNull(CurrentParticipantsTag::parse)
|
||||
|
||||
@@ -110,16 +102,19 @@ class LiveActivitiesEvent(
|
||||
|
||||
fun hosts() = tags.mapNotNull(ParticipantTag::parseHost)
|
||||
|
||||
fun checkStatus(eventStatus: String?): String? =
|
||||
if (eventStatus == StatusTag.STATUS.LIVE.code && createdAt < TimeUtils.eightHoursAgo()) {
|
||||
StatusTag.STATUS.ENDED.code
|
||||
} else {
|
||||
eventStatus
|
||||
}
|
||||
|
||||
fun checkStatusEnum(eventStatus: StatusTag.STATUS?): StatusTag.STATUS? =
|
||||
fun checkStatus(eventStatus: StatusTag.STATUS?): StatusTag.STATUS? =
|
||||
if (eventStatus == StatusTag.STATUS.LIVE && createdAt < TimeUtils.eightHoursAgo()) {
|
||||
StatusTag.STATUS.ENDED
|
||||
} else if (eventStatus == StatusTag.STATUS.PLANNED) {
|
||||
val starts = starts()
|
||||
val ends = ends()
|
||||
if (starts != null && starts < TimeUtils.oneHourAgo()) {
|
||||
StatusTag.STATUS.ENDED
|
||||
} else if (ends != null && ends < TimeUtils.oneHourAgo()) {
|
||||
StatusTag.STATUS.ENDED
|
||||
} else {
|
||||
eventStatus
|
||||
}
|
||||
} else {
|
||||
eventStatus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user