open remote url for unknown attachments (#4941)

closes https://github.com/tuskyapp/Tusky/issues/4729
This commit is contained in:
Konrad Pozniak 2025-02-24 14:18:24 +01:00 committed by GitHub
commit cd24ee8f26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 3 deletions

View file

@ -206,7 +206,7 @@ class AccountMediaFragment :
}
}
Attachment.Type.UNKNOWN -> {
context?.openLink(selected.attachment.url)
context?.openLink(selected.attachment.unknownUrl)
}
}
}

View file

@ -216,7 +216,7 @@ class SearchStatusesFragment : SearchFragment<StatusViewData.Concrete>(), Status
}
Attachment.Type.UNKNOWN -> {
context?.openLink(status.attachments[attachmentIndex].url)
context?.openLink(status.attachments[attachmentIndex].unknownUrl)
}
}
}

View file

@ -27,12 +27,18 @@ data class Attachment(
val url: String,
// can be null for e.g. audio attachments
@Json(name = "preview_url") val previewUrl: String? = null,
// null when local attachment
@Json(name = "remote_url") val remoteUrl: String? = null,
val meta: MetaData? = null,
val type: Type,
val description: String? = null,
val blurhash: String? = null
) : Parcelable {
/** The url to open for attachments of unknown type */
val unknownUrl: String
get() = remoteUrl ?: url
@JsonClass(generateAdapter = false)
enum class Type {
@Json(name = "image")

View file

@ -414,7 +414,7 @@ abstract class SFragment(@LayoutRes contentLayoutId: Int) : Fragment(contentLayo
}
Attachment.Type.UNKNOWN -> {
requireContext().openLink(attachment.url)
requireContext().openLink(attachment.unknownUrl)
}
}
}