1
0
mirror of https://github.com/tateisu/SubwayTooter synced 2025-02-08 08:09:02 +01:00

フォロー限定投稿にフォロー外から返信しようとした際のエラー表示を改善

This commit is contained in:
tateisu 2023-07-11 09:09:43 +09:00
parent 8dc33e1b70
commit 6ac8545b58
4 changed files with 37 additions and 20 deletions

View File

@ -607,7 +607,19 @@ class PostImpl(
status != null -> status != null ->
PostResult.Normal(account, status) PostResult.Normal(account, status)
else -> error(result.error ?: "(result.error is null)") else -> {
val e = result.error
error(
when {
e.isNullOrBlank() -> "(missing result.error)"
e.contains("HTTP 404") ->
"$e\n${activity.getString(R.string.post_404_desc)}"
else -> e
}
)
}
} }
} }
} }

View File

@ -1289,4 +1289,5 @@
<string name="use_webp_format_if_server_accepts">可能ならWebPフォーマットを使う</string> <string name="use_webp_format_if_server_accepts">可能ならWebPフォーマットを使う</string>
<string name="detail">詳細</string> <string name="detail">詳細</string>
<string name="emoji_detail">絵文字の詳細</string> <string name="emoji_detail">絵文字の詳細</string>
<string name="post_404_desc">(もしくは、フォロー限定投稿にフォロー外から返信しようとしました)</string>
</resources> </resources>

View File

@ -1300,4 +1300,5 @@
<string name="use_webp_format_if_server_accepts">Use WebP format if server accepts.</string> <string name="use_webp_format_if_server_accepts">Use WebP format if server accepts.</string>
<string name="detail">Detail</string> <string name="detail">Detail</string>
<string name="emoji_detail">Emoji detail</string> <string name="emoji_detail">Emoji detail</string>
<string name="post_404_desc">(Or, you reply to follower-only post from other account)</string>
</resources> </resources>

View File

@ -188,10 +188,7 @@ fun AppCompatActivity.showError(ex: Throwable, caption: String? = null) {
if (ex is CancellationException) return if (ex is CancellationException) return
try { try {
AlertDialog.Builder(this) val text = listOf(
.setTitle("error")
.setMessage(
listOf(
caption, caption,
when (ex) { when (ex) {
is IllegalStateException -> null is IllegalStateException -> null
@ -201,10 +198,16 @@ fun AppCompatActivity.showError(ex: Throwable, caption: String? = null) {
) )
.filter { !it.isNullOrBlank() } .filter { !it.isNullOrBlank() }
.joinToString("\n") .joinToString("\n")
) if (text.isNotEmpty()) {
} catch (ignored: Throwable) { AlertDialog.Builder(this)
showToast(ex, caption) .setMessage(text)
.setPositiveButton(android.R.string.ok, null)
.show()
return
} }
} catch (ignored: Throwable) {
}
showToast(ex, caption)
} }
fun Context.errorString(@StringRes stringId: Int, vararg args: Any?): Nothing = fun Context.errorString(@StringRes stringId: Int, vararg args: Any?): Nothing =