fix: issue in which exotic links can cause a crash
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
f769dcb315
commit
e69fd44108
|
|
@ -1,5 +1,6 @@
|
|||
package chat.revolt.components.markdown
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.browser.customtabs.CustomTabColorSchemeParams
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.compose.foundation.layout.height
|
||||
|
|
@ -33,6 +34,7 @@ import androidx.compose.ui.text.font.FontSynthesis
|
|||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import chat.revolt.R
|
||||
import chat.revolt.api.REVOLT_FILES
|
||||
import chat.revolt.api.RevoltAPI
|
||||
import chat.revolt.api.routes.custom.fetchEmoji
|
||||
|
|
@ -292,7 +294,16 @@ fun MarkdownText(textNode: AstNode, modifier: Modifier = Modifier) {
|
|||
.build()
|
||||
)
|
||||
.build()
|
||||
customTab.launchUrl(context, url.toUri())
|
||||
|
||||
try {
|
||||
customTab.launchUrl(context, url.toUri())
|
||||
} catch (e: Exception) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(R.string.link_type_no_intent),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
return@handler true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -410,6 +410,8 @@
|
|||
<string name="report_block_yes">Block</string>
|
||||
<string name="report_block_no">Don\'t block</string>
|
||||
|
||||
<string name="link_type_no_intent">No app found to handle this link</string>
|
||||
|
||||
<string name="invite_message">You\'ve been invited to join this server. Would you like to join?</string>
|
||||
<string name="invite_join">Join</string>
|
||||
<string name="invite_cancel">Cancel</string>
|
||||
|
|
|
|||
Loading…
Reference in New Issue