diff --git a/app/src/main/java/chat/revolt/api/routes/channel/Channel.kt b/app/src/main/java/chat/revolt/api/routes/channel/Channel.kt
index a842e401..e2608c9d 100644
--- a/app/src/main/java/chat/revolt/api/routes/channel/Channel.kt
+++ b/app/src/main/java/chat/revolt/api/routes/channel/Channel.kt
@@ -170,4 +170,14 @@ suspend fun createInvite(channelId: String): CreateInviteResponse {
if (error.type != "Server") throw Error(error.type)
return RevoltJson.decodeFromString(CreateInviteResponse.serializer(), response)
+}
+
+suspend fun fetchSingleMessage(channelId: String, messageId: String): Message {
+ val response = RevoltHttp.get("/channels/$channelId/messages/$messageId")
+ .bodyAsText()
+
+ return RevoltJson.decodeFromString(
+ Message.serializer(),
+ response
+ )
}
\ No newline at end of file
diff --git a/app/src/main/java/chat/revolt/components/chat/InReplyTo.kt b/app/src/main/java/chat/revolt/components/chat/InReplyTo.kt
index 7baa86e5..eb055604 100644
--- a/app/src/main/java/chat/revolt/components/chat/InReplyTo.kt
+++ b/app/src/main/java/chat/revolt/components/chat/InReplyTo.kt
@@ -12,6 +12,7 @@ import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
@@ -25,11 +26,13 @@ import androidx.compose.ui.unit.sp
import chat.revolt.R
import chat.revolt.api.RevoltAPI
import chat.revolt.api.internals.solidColor
+import chat.revolt.api.routes.channel.fetchSingleMessage
import chat.revolt.api.schemas.User
import chat.revolt.components.generic.UserAvatar
@Composable
fun InReplyTo(
+ channelId: String,
messageId: String,
modifier: Modifier = Modifier,
withMention: Boolean = false,
@@ -46,6 +49,12 @@ fun InReplyTo(
val usernameColor =
message?.let { authorColour(it) } ?: Brush.solidColor(contentColor)
+ LaunchedEffect(messageId) {
+ if (messageId !in RevoltAPI.messageCache) {
+ RevoltAPI.messageCache[messageId] = fetchSingleMessage(channelId, messageId)
+ }
+ }
+
Box(
modifier = modifier
.fillMaxWidth()
@@ -96,19 +105,32 @@ fun InReplyTo(
}
)
- Text(
- text = message.content ?: "",
- fontSize = 12.sp,
- color = contentColor.copy(alpha = 0.7f),
- maxLines = 1,
- overflow = TextOverflow.Ellipsis
- )
+ if (message.content.isNullOrBlank()) {
+ Text(
+ text = stringResource(id = R.string.reply_message_empty_has_attachments),
+ // TODO: inter has italics now, import and use them
+ fontStyle = FontStyle.Italic, // inter doesn't have italics...
+ fontSize = 12.sp,
+ fontFamily = FontFamily.Default, // ...so we use the default font
+ color = contentColor.copy(alpha = 0.7f),
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ } else {
+ Text(
+ text = message.content,
+ fontSize = 12.sp,
+ color = contentColor.copy(alpha = 0.7f),
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis
+ )
+ }
} else {
Text(
text = stringResource(id = R.string.reply_message_not_cached),
- fontStyle = FontStyle.Italic, // inter doesn't have italics...
+ fontStyle = FontStyle.Italic, // inter _still_ doesn't have italics...
color = contentColor.copy(alpha = 0.7f),
- fontFamily = FontFamily.Default, // ...so we use the defaul t font
+ fontFamily = FontFamily.Default, // ...so we use the default font
fontSize = 12.sp,
maxLines = 1,
overflow = TextOverflow.Ellipsis
diff --git a/app/src/main/java/chat/revolt/components/chat/Message.kt b/app/src/main/java/chat/revolt/components/chat/Message.kt
index 987ddd0c..307ac2e5 100644
--- a/app/src/main/java/chat/revolt/components/chat/Message.kt
+++ b/app/src/main/java/chat/revolt/components/chat/Message.kt
@@ -65,10 +65,10 @@ import chat.revolt.activities.media.ImageViewActivity
import chat.revolt.activities.media.VideoViewActivity
import chat.revolt.api.REVOLT_FILES
import chat.revolt.api.RevoltAPI
+import chat.revolt.api.internals.BrushCompat
import chat.revolt.api.internals.Roles
import chat.revolt.api.internals.SpecialUsers
import chat.revolt.api.internals.ULID
-import chat.revolt.api.internals.BrushCompat
import chat.revolt.api.internals.solidColor
import chat.revolt.api.routes.channel.react
import chat.revolt.api.routes.channel.unreact
@@ -212,18 +212,21 @@ fun Message(
message.replies?.forEach { reply ->
val replyMessage = RevoltAPI.messageCache[reply]
- InReplyTo(
- messageId = reply,
- withMention = replyMessage?.author?.let {
- message.mentions?.contains(
- replyMessage.author
- )
- }
- ?: false
- ) {
- // TODO Add jump to message
- if (replyMessage == null) {
- Toast.makeText(context, "lmao prankd", Toast.LENGTH_SHORT).show()
+ message.channel?.let { chId ->
+ InReplyTo(
+ channelId = chId,
+ messageId = reply,
+ withMention = replyMessage?.author?.let {
+ message.mentions?.contains(
+ replyMessage.author
+ )
+ }
+ ?: false
+ ) {
+ // TODO Add jump to message
+ if (replyMessage == null) {
+ Toast.makeText(context, "lmao prankd", Toast.LENGTH_SHORT).show()
+ }
}
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ad38c977..dddb315c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -177,7 +177,7 @@
You don\'t have permission to send messages in this channel.
This is a trusted channel for notices from our moderation team. You can\'t send messages here.
- Unknown message, tap to jump
+ Unknown message
Sent attachments
Ownership changed