Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mastodon notification crash #530

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading