Adds content warning reason to all new post screens

This commit is contained in:
Vitor Pamplona
2026-03-11 13:52:18 -04:00
parent 7ce13b5ba5
commit a4010189cd
5 changed files with 34 additions and 5 deletions
@@ -81,6 +81,7 @@ import com.vitorpamplona.quartz.nip30CustomEmoji.CustomEmoji
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrlTag
import com.vitorpamplona.quartz.nip30CustomEmoji.emojis
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarningReason
import com.vitorpamplona.quartz.nip36SensitiveContent.isSensitive
import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent
import com.vitorpamplona.quartz.nip57Zaps.splits.zapSplits
@@ -166,6 +167,7 @@ open class CommentPostViewModel :
// NSFW, Sensitive
var wantsToMarkAsSensitive by mutableStateOf(false)
var contentWarningDescription by mutableStateOf("")
// GeoHash
var wantsToAddGeoHash by mutableStateOf(false)
@@ -270,6 +272,7 @@ open class CommentPostViewModel :
wantsForwardZapTo = localForwardZapTo.isNotEmpty()
wantsToMarkAsSensitive = draftEvent.isSensitive()
contentWarningDescription = draftEvent.contentWarningReason() ?: ""
val zapraiser = draftEvent.zapraiserAmount()
wantsZapraiser = zapraiser != null
@@ -359,7 +362,7 @@ open class CommentPostViewModel :
val zapReceiver = if (wantsForwardZapTo) forwardZapTo.value.toZapSplitSetup() else null
val localZapRaiserAmount = if (wantsZapraiser) zapRaiserAmount.value else null
val contentWarningReason = if (wantsToMarkAsSensitive) "" else null
val contentWarningReason = if (wantsToMarkAsSensitive) contentWarningDescription else null
val replyingTo = replyingTo
val replyingToEvent = replyingTo?.event
@@ -555,6 +558,7 @@ open class CommentPostViewModel :
wantsForwardZapTo = false
wantsToMarkAsSensitive = false
contentWarningDescription = ""
wantsToAddGeoHash = false
wantsSecretEmoji = false
@@ -77,6 +77,7 @@ import com.vitorpamplona.quartz.nip30CustomEmoji.CustomEmoji
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrlTag
import com.vitorpamplona.quartz.nip30CustomEmoji.emojis
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarningReason
import com.vitorpamplona.quartz.nip36SensitiveContent.isSensitive
import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent
import com.vitorpamplona.quartz.nip40Expiration.expiration
@@ -160,6 +161,7 @@ class ChatNewMessageViewModel :
// NSFW, Sensitive
var wantsToMarkAsSensitive by mutableStateOf(false)
var contentWarningDescription by mutableStateOf("")
// GeoHash
var wantsToAddGeoHash by mutableStateOf(false)
@@ -292,6 +294,7 @@ class ChatNewMessageViewModel :
wantsForwardZapTo = localForwardZapTo.isNotEmpty()
wantsToMarkAsSensitive = draftEvent.isSensitive()
contentWarningDescription = draftEvent.contentWarningReason() ?: ""
val geohash = draftEvent.getGeoHash()
wantsToAddGeoHash = geohash != null
@@ -440,7 +443,7 @@ class ChatNewMessageViewModel :
val geoHash = if (wantsToAddGeoHash) (location?.value as? LocationState.LocationResult.Success)?.geoHash?.toString() else null
val message = message.text
val contentWarningReason = if (wantsToMarkAsSensitive) "" else null
val contentWarningReason = if (wantsToMarkAsSensitive) contentWarningDescription else null
val localZapRaiserAmount = if (wantsZapraiser) zapRaiserAmount.value else null
val zapReceiver = if (wantsForwardZapTo) forwardZapTo.value.toZapSplitSetup() else null
@@ -538,6 +541,7 @@ class ChatNewMessageViewModel :
wantsForwardZapTo = false
wantsToMarkAsSensitive = false
contentWarningDescription = ""
wantsToAddGeoHash = false
wantsSecretEmoji = false
@@ -81,6 +81,8 @@ import com.vitorpamplona.quartz.nip28PublicChat.message.ChannelMessageEvent
import com.vitorpamplona.quartz.nip30CustomEmoji.CustomEmoji
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrlTag
import com.vitorpamplona.quartz.nip30CustomEmoji.emojis
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarningReason
import com.vitorpamplona.quartz.nip36SensitiveContent.isSensitive
import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent
import com.vitorpamplona.quartz.nip53LiveActivities.chat.LiveActivitiesChatMessageEvent
@@ -145,6 +147,7 @@ open class ChannelNewMessageViewModel :
// NSFW, Sensitive
var wantsToMarkAsSensitive by mutableStateOf(false)
var contentWarningDescription by mutableStateOf("")
// GeoHash
var wantsToAddGeoHash by mutableStateOf(false)
@@ -224,6 +227,7 @@ open class ChannelNewMessageViewModel :
wantsForwardZapTo = localForwardZapTo.isNotEmpty()
wantsToMarkAsSensitive = draftEvent.isSensitive()
contentWarningDescription = draftEvent.contentWarningReason() ?: ""
val geohash = draftEvent.getGeoHash()
wantsToAddGeoHash = geohash != null
@@ -383,6 +387,8 @@ open class ChannelNewMessageViewModel :
val channelRelays = channel.relays()
val geoHash = if (wantsToAddGeoHash) (location?.value as? LocationState.LocationResult.Success)?.geoHash?.toString() else null
val contentWarningReason = if (wantsToMarkAsSensitive) contentWarningDescription else null
return if (channel is PublicChatChannel) {
val replyingToEvent = replyTo.value?.toEventHint<ChannelMessageEvent>()
val channelEvent = channel.event
@@ -394,6 +400,7 @@ open class ChannelNewMessageViewModel :
hashtags(findHashtags(tagger.message))
references(findURLs(tagger.message))
quotes(findNostrUris(tagger.message))
contentWarningReason?.let { contentWarning(it) }
geoHash?.let { geohash(it) }
@@ -406,6 +413,7 @@ open class ChannelNewMessageViewModel :
hashtags(findHashtags(tagger.message))
references(findURLs(tagger.message))
quotes(findNostrUris(tagger.message))
contentWarningReason?.let { contentWarning(it) }
geoHash?.let { geohash(it) }
@@ -417,6 +425,7 @@ open class ChannelNewMessageViewModel :
hashtags(findHashtags(tagger.message))
references(findURLs(tagger.message))
quotes(findNostrUris(tagger.message))
contentWarningReason?.let { contentWarning(it) }
geoHash?.let { geohash(it) }
@@ -435,6 +444,7 @@ open class ChannelNewMessageViewModel :
hashtags(findHashtags(tagger.message))
references(findURLs(tagger.message))
quotes(findNostrUris(tagger.message))
contentWarningReason?.let { contentWarning(it) }
emojis(emojis)
imetas(usedAttachments)
@@ -446,6 +456,7 @@ open class ChannelNewMessageViewModel :
hashtags(findHashtags(tagger.message))
references(findURLs(tagger.message))
quotes(findNostrUris(tagger.message))
contentWarningReason?.let { contentWarning(it) }
emojis(emojis)
imetas(usedAttachments)
@@ -455,6 +466,7 @@ open class ChannelNewMessageViewModel :
hashtags(findHashtags(tagger.message))
references(findURLs(tagger.message))
quotes(findNostrUris(tagger.message))
contentWarningReason?.let { contentWarning(it) }
emojis(emojis)
imetas(usedAttachments)
@@ -469,6 +481,7 @@ open class ChannelNewMessageViewModel :
hashtags(findHashtags(tagger.message))
references(findURLs(tagger.message))
quotes(findNostrUris(tagger.message))
contentWarningReason?.let { contentWarning(it) }
emojis(emojis)
imetas(usedAttachments)
@@ -503,7 +516,7 @@ open class ChannelNewMessageViewModel :
wantsForwardZapTo = false
wantsToMarkAsSensitive = false
contentWarningDescription = ""
wantsToAddGeoHash = false
forwardZapTo = SplitBuilder()
@@ -76,6 +76,7 @@ import com.vitorpamplona.quartz.nip30CustomEmoji.CustomEmoji
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrlTag
import com.vitorpamplona.quartz.nip30CustomEmoji.emojis
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarningReason
import com.vitorpamplona.quartz.nip36SensitiveContent.isSensitive
import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent
import com.vitorpamplona.quartz.nip57Zaps.splits.zapSplits
@@ -157,6 +158,7 @@ open class NewProductViewModel :
// NSFW, Sensitive
var wantsToMarkAsSensitive by mutableStateOf(false)
var contentWarningDescription by mutableStateOf("")
// GeoHash
var wantsToAddGeoHash by mutableStateOf(false)
@@ -250,6 +252,7 @@ open class NewProductViewModel :
wantsForwardZapTo = localfowardZapTo.isNotEmpty()
wantsToMarkAsSensitive = draftEvent.isSensitive()
contentWarningDescription = draftEvent.contentWarningReason() ?: ""
val geohash = draftEvent.getGeoHash()
wantsToAddGeoHash = geohash != null
@@ -329,7 +332,7 @@ open class NewProductViewModel :
val zapReceiver = if (wantsForwardZapTo) forwardZapTo.value.toZapSplitSetup() else null
val localZapRaiserAmount = if (wantsZapraiser) zapRaiserAmount.value else null
val contentWarningReason = if (wantsToMarkAsSensitive) "" else null
val contentWarningReason = if (wantsToMarkAsSensitive) contentWarningDescription else null
val quotes = findNostrUris(tagger.message)
@@ -450,6 +453,7 @@ open class NewProductViewModel :
wantsForwardZapTo = false
wantsToMarkAsSensitive = false
contentWarningDescription = ""
wantsToAddGeoHash = false
wantsSecretEmoji = false
@@ -83,6 +83,7 @@ import com.vitorpamplona.quartz.nip30CustomEmoji.CustomEmoji
import com.vitorpamplona.quartz.nip30CustomEmoji.EmojiUrlTag
import com.vitorpamplona.quartz.nip30CustomEmoji.emojis
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarningReason
import com.vitorpamplona.quartz.nip36SensitiveContent.isSensitive
import com.vitorpamplona.quartz.nip37Drafts.DraftWrapEvent
import com.vitorpamplona.quartz.nip57Zaps.splits.ZapSplitSetup
@@ -168,6 +169,7 @@ class NewPublicMessageViewModel :
// NSFW, Sensitive
var wantsToMarkAsSensitive by mutableStateOf(false)
var contentWarningDescription by mutableStateOf("")
// GeoHash
var wantsToAddGeoHash by mutableStateOf(false)
@@ -266,6 +268,7 @@ class NewPublicMessageViewModel :
wantsForwardZapTo = localForwardZapTo.isNotEmpty()
wantsToMarkAsSensitive = draftEvent.isSensitive()
contentWarningDescription = draftEvent.contentWarningReason() ?: ""
val geohash = draftEvent.getGeoHash()
wantsToAddGeoHash = geohash != null
@@ -364,7 +367,7 @@ class NewPublicMessageViewModel :
val urls = findURLs(tagger.message)
val usedAttachments = iMetaAttachments.filterIsIn(urls.toSet())
val contentWarningReason = if (wantsToMarkAsSensitive) "" else null
val contentWarningReason = if (wantsToMarkAsSensitive) contentWarningDescription else null
return PublicMessageEvent.build(
to = toUsers.toList(),
@@ -493,6 +496,7 @@ class NewPublicMessageViewModel :
wantsForwardZapTo = false
wantsToMarkAsSensitive = false
contentWarningDescription = ""
wantsToAddGeoHash = false
wantsSecretEmoji = false