diff --git a/CHANGELOG.md b/CHANGELOG.md index 61ed5807..ad69b185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +* Fix crash when trying to open a comments-only post from + the home screen widget + ## [1.42.0] - 2024-03-16 ### Fixed diff --git a/android/src/main/kotlin/dev/msfjarvis/claw/android/glance/WidgetListEntry.kt b/android/src/main/kotlin/dev/msfjarvis/claw/android/glance/WidgetListEntry.kt index 1b08da69..6d6ef02f 100644 --- a/android/src/main/kotlin/dev/msfjarvis/claw/android/glance/WidgetListEntry.kt +++ b/android/src/main/kotlin/dev/msfjarvis/claw/android/glance/WidgetListEntry.kt @@ -43,9 +43,10 @@ fun WidgetListEntry(post: UIPost, modifier: GlanceModifier = GlanceModifier) { val titleStyle = MaterialTheme.typography.titleMedium val commentsAction = actionStartActivity(actionParametersOf(destinationKey to post.shortId)) + // If the URL starts with a /, it's a relative URL and we should open the comments page directly. val postAction = - if (post.url.isNotEmpty()) actionStartActivity(Intent(Intent.ACTION_VIEW, Uri.parse(post.url))) - else commentsAction + if (post.url.startsWith('/')) commentsAction + else actionStartActivity(Intent(Intent.ACTION_VIEW, Uri.parse(post.url))) Box(modifier.padding(8.dp)) { Row( verticalAlignment = Alignment.CenterVertically,