fix translations not working on instances where domain does not match instance name (#4560)

https://social.froonix.org/@cs/112767747835228296

We were caching the instance info with the instance name as the key and
then look it up with the actual domain and those do not always match so
the check if translation is supported fails. fnx.li vs
social.froonix.org in this case.
This commit is contained in:
Konrad Pozniak 2024-07-12 11:06:39 +02:00 committed by GitHub
parent 0dfc77e2a2
commit 235b55d8d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -17,6 +17,7 @@ package com.keylesspalace.tusky.components.instanceinfo
import android.util.Log
import at.connyduck.calladapter.networkresult.NetworkResult
import at.connyduck.calladapter.networkresult.fold
import at.connyduck.calladapter.networkresult.getOrElse
import at.connyduck.calladapter.networkresult.getOrThrow
import at.connyduck.calladapter.networkresult.map
@ -65,9 +66,11 @@ class InstanceInfoRepository @Inject constructor(
// - caching default value (we want to rather re-fetch if it fails)
if (instanceInfoCache[instanceName] == null) {
externalScope.launch {
fetchAndPersistInstanceInfo().onSuccess { fetched ->
instanceInfoCache[fetched.instance] = fetched.toInfoOrDefault()
}
fetchAndPersistInstanceInfo().fold({ fetched ->
instanceInfoCache[instanceName] = fetched.toInfoOrDefault()
}, { e ->
Log.w(TAG, "failed to precache instance info", e)
})
}
}
}