Skip to content

Commit

Permalink
Merge pull request #530 from DimensionDev/bugfix/mastodon_notificatio…
Browse files Browse the repository at this point in the history
…n_crash

fix mastodon notification crash
  • Loading branch information
Tlaster authored Oct 23, 2024
2 parents f2895b4 + 56b02e8 commit 8060333
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private fun TopMessageComponent(
UiTimeline.TopMessage.Icon.Reply -> FontAwesomeIcons.Solid.Reply
UiTimeline.TopMessage.Icon.Quote -> FontAwesomeIcons.Solid.QuoteLeft
}
val text: String =
val text: String? =
when (val type = data.type) {
is UiTimeline.TopMessage.MessageType.Bluesky ->
when (type) {
Expand Down Expand Up @@ -249,6 +249,8 @@ private fun TopMessageComponent(
stringResource(
id = R.string.mastodon_notification_item_updated_status,
)

is UiTimeline.TopMessage.MessageType.Mastodon.UnKnown -> null
}

is UiTimeline.TopMessage.MessageType.Misskey ->
Expand Down Expand Up @@ -325,22 +327,24 @@ private fun TopMessageComponent(
}
}

StatusRetweetHeaderComponent(
icon = icon,
user = data.user,
text = text,
modifier =
modifier
.clickable {
data.onClicked.invoke(
ClickContext(
launcher = {
uriHandler.openUri(it)
},
),
)
},
)
if (text != null) {
StatusRetweetHeaderComponent(
icon = icon,
user = data.user,
text = text,
modifier =
modifier
.clickable {
data.onClicked.invoke(
ClickContext(
launcher = {
uriHandler.openUri(it)
},
),
)
},
)
}
}

val MisskeyAchievement.titleResId: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ struct StatusRetweetHeaderComponent: View {
case .reblogged: String(localized: "mastodon_notification_reblog")
case .status: String(localized: "mastodon_notification_status")
case .update: String(localized: "mastodon_notification_update")
case .unKnown: String(localized: "mastodon_notification_update")
}
case .misskey(let data):
switch onEnum(of: data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ data class UiTimeline internal constructor(
data class Update(
val id: String,
) : Mastodon

data class UnKnown(
val id: String,
) : Mastodon
}

sealed interface Misskey : MessageType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ internal fun Notification.render(
NotificationTypes.Update ->
UiTimeline.TopMessage.MessageType.Mastodon
.Update(id = id.orEmpty())
null -> null
null ->
UiTimeline.TopMessage.MessageType.Mastodon
.UnKnown(id = id.orEmpty())
}
val topMessage =
topMessageType?.let {
topMessageType.let {
UiTimeline.TopMessage(
user = user,
icon =
Expand Down

0 comments on commit 8060333

Please sign in to comment.