fix: Prevent crash showing profile if account has null `createdAt` field

This commit is contained in:
Nik Clayton 2023-12-09 22:30:31 +01:00
parent d4eed2fbf8
commit df45c0cd96
2 changed files with 10 additions and 8 deletions

View File

@ -503,13 +503,15 @@ class AccountActivity :
private fun updateAccountJoinedDate() {
loadedAccount?.let { account ->
try {
account.createdAt?.let { createdAt ->
binding.accountDateJoined.text = resources.getString(
R.string.account_date_joined,
SimpleDateFormat("MMMM, yyyy", Locale.getDefault()).format(account.createdAt),
SimpleDateFormat("MMMM, yyyy", Locale.getDefault()).format(createdAt),
)
binding.accountDateJoined.visibility = View.VISIBLE
binding.accountDateJoined.show()
} ?: binding.accountDateJoined.hide()
} catch (e: ParseException) {
binding.accountDateJoined.visibility = View.GONE
binding.accountDateJoined.hide()
}
}
}

View File

@ -23,8 +23,8 @@ data class Account(
val id: String,
@SerializedName("username") val localUsername: String,
@SerializedName("acct") val username: String,
@SerializedName("display_name") val displayName: String?, // should never be null per Api definition, but some servers break the contract
@SerializedName("created_at") val createdAt: Date,
@SerializedName("display_name") val displayName: String?, // should never be null per API definition, but some servers break the contract
@SerializedName("created_at") val createdAt: Date?, // should never be null per API definition, but some servers break the contract
val note: String,
val url: String,
val avatar: String,