fix: log image load errors and show placeholder on error

This commit is contained in:
Jannis Mattheis
2024-06-22 13:21:09 +02:00
parent 7d6399b087
commit 337af76b58
3 changed files with 64 additions and 16 deletions

View File

@@ -20,6 +20,7 @@ import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import org.threeten.bp.OffsetDateTime
import org.tinylog.kotlin.Logger
@@ -92,4 +93,13 @@ internal object Utils {
context.getSystemService(ActivityManager::class.java).appTasks?.getOrNull(0)
?.setExcludeFromRecents(excludeFromRecent)
}
fun redactPassword(stringUrl: String?): String {
val url = stringUrl?.toHttpUrlOrNull()
return when {
url == null -> "unknown"
url.password.isEmpty() -> url.toString()
else -> url.newBuilder().password("REDACTED").toString()
}
}
}