refactor: Move ServerRepository to core.data (#728)

This commit is contained in:
Nik Clayton 2024-06-10 16:08:48 +02:00 committed by GitHub
parent a2fa9f60fb
commit e4a065ca9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 61 additions and 46 deletions

View File

@ -31,6 +31,7 @@ import app.pachli.appstore.MainTabsChangedEvent
import app.pachli.core.activity.BottomSheetActivity
import app.pachli.core.common.extensions.viewBinding
import app.pachli.core.common.util.unsafeLazy
import app.pachli.core.data.repository.ServerRepository
import app.pachli.core.model.Timeline
import app.pachli.core.navigation.TimelineActivityIntent
import app.pachli.core.network.ServerOperation.ORG_JOINMASTODON_FILTERS_CLIENT
@ -41,7 +42,6 @@ import app.pachli.core.network.model.FilterV1
import app.pachli.databinding.ActivityTimelineBinding
import app.pachli.interfaces.ActionButtonActivity
import app.pachli.interfaces.AppBarLayoutHost
import app.pachli.network.ServerRepository
import at.connyduck.calladapter.networkresult.fold
import com.github.michaelbull.result.getOrElse
import com.google.android.material.appbar.AppBarLayout

View File

@ -29,6 +29,7 @@ import app.pachli.core.accounts.AccountManager
import app.pachli.core.activity.extensions.TransitionKind
import app.pachli.core.activity.extensions.startActivityWithTransition
import app.pachli.core.common.util.unsafeLazy
import app.pachli.core.data.repository.ServerRepository
import app.pachli.core.designsystem.R as DR
import app.pachli.core.navigation.AccountListActivityIntent
import app.pachli.core.navigation.FiltersActivityIntent
@ -45,7 +46,6 @@ import app.pachli.core.network.model.Account
import app.pachli.core.network.model.Status
import app.pachli.core.network.retrofit.MastodonApi
import app.pachli.core.preferences.PrefKeys
import app.pachli.network.ServerRepository
import app.pachli.settings.AccountPreferenceDataStore
import app.pachli.settings.listPreference
import app.pachli.settings.makePreferenceScreen

View File

@ -17,12 +17,12 @@
package app.pachli.components.timeline
import app.pachli.core.data.repository.ServerRepository
import app.pachli.core.network.ServerOperation.ORG_JOINMASTODON_FILTERS_CLIENT
import app.pachli.core.network.ServerOperation.ORG_JOINMASTODON_FILTERS_SERVER
import app.pachli.core.network.model.Filter
import app.pachli.core.network.model.FilterV1
import app.pachli.core.network.retrofit.MastodonApi
import app.pachli.network.ServerRepository
import at.connyduck.calladapter.networkresult.fold
import at.connyduck.calladapter.networkresult.getOrThrow
import com.github.michaelbull.result.getOrElse

View File

@ -47,6 +47,7 @@ import app.pachli.core.activity.BottomSheetActivity
import app.pachli.core.activity.PostLookupFallbackBehavior
import app.pachli.core.activity.extensions.startActivityWithDefaultTransition
import app.pachli.core.activity.openLink
import app.pachli.core.data.repository.ServerRepository
import app.pachli.core.database.model.AccountEntity
import app.pachli.core.database.model.TranslationState
import app.pachli.core.navigation.AttachmentViewData
@ -62,7 +63,6 @@ import app.pachli.core.network.parseAsMastodonHtml
import app.pachli.core.network.retrofit.MastodonApi
import app.pachli.core.ui.extensions.getErrorString
import app.pachli.interfaces.StatusActionListener
import app.pachli.network.ServerRepository
import app.pachli.usecase.TimelineCases
import app.pachli.view.showMuteAccountDialog
import app.pachli.viewdata.IStatusViewData

View File

@ -21,11 +21,11 @@ import androidx.annotation.VisibleForTesting
import androidx.annotation.VisibleForTesting.Companion.PRIVATE
import app.pachli.core.accounts.AccountManager
import app.pachli.core.common.di.ApplicationScope
import app.pachli.core.data.repository.ServerRepository
import app.pachli.core.database.model.AccountEntity
import app.pachli.core.network.ServerOperation.ORG_JOINMASTODON_STATUSES_TRANSLATE
import app.pachli.core.preferences.PrefKeys
import app.pachli.core.preferences.SharedPreferencesRepository
import app.pachli.network.ServerRepository
import app.pachli.settings.AccountPreferenceDataStore
import com.github.michaelbull.result.onFailure
import com.github.michaelbull.result.onSuccess

View File

@ -641,13 +641,7 @@
<string name="action_translate_undo">Deshacer traducción</string>
<string name="notification_prune_cache">Mantenimiento de caché…</string>
<string name="pref_summary_timeline_filters">Tu servidor no soporta los filtros</string>
<string name="server_repository_error_unsupported_schema">/.well-known/nodeinfo no contiene esquemas comprensibles</string>
<string name="server_repository_error_get_node_info">fallo al obtener nodeinfo %1$s: %2$s</string>
<string name="server_repository_error_validate_node_info">fallo al validar nodeinfo %1$s: %2$s</string>
<string name="server_repository_error_get_instance_info">fallo al obtener /api/v1/instance: %1$s</string>
<string name="server_repository_error">No se pudo obtener la info del servidor %1$s: %2$s</string>
<string name="server_repository_error_get_well_known_node_info">fallo al obtener /.well-known/nodeinfo: %1$s</string>
<string name="server_repository_error_capabilities">fallo al analizar las capacidades del servidor: %1$s</string>
<string name="error_media_download">No se pudo descargar %1$s: %2$d %3$s</string>
<string name="pref_title_update_check_now">Buscar actualizaciones ahora</string>
<string name="pref_update_check_no_updates">No hay actualizaciones disponibles</string>

View File

@ -624,13 +624,7 @@
<string name="duration_no_change">(Ei muutosta)</string>
<string name="description_post_media">Media: %s</string>
<string name="pref_summary_timeline_filters">Palvelimesi ei tue suodattimia</string>
<string name="server_repository_error_unsupported_schema">/.well-known/nodeinfo ei sisältänyt ymmärrettäviä kaavoja</string>
<string name="server_repository_error_get_node_info">solmun tietojen haku osoitteesta %1$s epäonnistui: %2$s</string>
<string name="server_repository_error_get_instance_info">haku /api/v1/instance epäonnistui: %1$s</string>
<string name="server_repository_error_capabilities">palvelimen tietojen jäsentely epäonnistui: %1$s</string>
<string name="server_repository_error">Palvelintietoja ei voitu hakea osoitteelle %1$s:%2$s</string>
<string name="server_repository_error_get_well_known_node_info">haku /.well-known/nodeinfo epäonnistui: %1$s</string>
<string name="server_repository_error_validate_node_info">solmun %1$s tietojen validointi epäonnistui: %2$s</string>
<string name="pref_title_update_check_now">Etsi päivitystä nyt</string>
<string name="pref_update_next_scheduled_check">Seuraava ajoitettu tarkistus: %1$s</string>
<string name="pref_update_check_no_updates">Ei päivityksiä tarjolla</string>

View File

@ -631,12 +631,6 @@
<string name="notification_prune_cache">Cache onderhoud…</string>
<string name="pref_ui_text_size">UI tekst grootte</string>
<string name="server_repository_error">Kon geen server info ophalen voor %1$s: %2$s</string>
<string name="server_repository_error_get_well_known_node_info">ophalen /.well-known/nodeinfo mislukt: %1$s</string>
<string name="server_repository_error_unsupported_schema">/.well-known/nodeinfo bevatte geen begrijpbare schemas</string>
<string name="server_repository_error_get_node_info">ophalen nodeinfo %1$s mislukt: %2$s</string>
<string name="server_repository_error_validate_node_info">valideren van nodeinfo %1$s mislukt: %2$s</string>
<string name="server_repository_error_get_instance_info">ophalen van /api/v1/instance mislukt: %1$s</string>
<string name="server_repository_error_capabilities">verwerken van server mogelijkheden mislukt: %1$s</string>
<string name="pref_title_update_check_now">Controleer nu op update</string>
<string name="pref_update_check_no_updates">Er zijn geen updates beschikbaar</string>
<string name="pref_update_next_scheduled_check">Volgende geplande controle: %1$s</string>

View File

@ -637,11 +637,5 @@
<string name="label_image">Bild</string>
<string name="action_translate_undo">Ångra översättning</string>
<string name="server_repository_error">Kunde inte hämta serverinformation för %1$s: %2$s</string>
<string name="server_repository_error_get_well_known_node_info">misslyckades med att hämta /.well-known/nodeinfo: %1$s</string>
<string name="server_repository_error_unsupported_schema">/.well-known/nodeinfo innehöll inte begripliga scheman</string>
<string name="server_repository_error_get_node_info">hämtning av nodeinfo %1$s misslyckades: %2$s</string>
<string name="server_repository_error_validate_node_info">validering av nodeinfo %1$s misslyckades: %2$s</string>
<string name="server_repository_error_get_instance_info">hämtning av /api/v1/instance misslyckades: %1$s</string>
<string name="server_repository_error_capabilities">tolkning av serverfunktioner misslyckades: %1$s</string>
<string name="pref_summary_timeline_filters">Din server stöder inte filter</string>
</resources>

View File

@ -687,12 +687,6 @@
<string name="translation_provider_fmt">%1$s</string>
<string name="server_repository_error">Could not fetch server info for %1$s: %2$s</string>
<string name="server_repository_error_get_well_known_node_info">fetching /.well-known/nodeinfo failed: %1$s</string>
<string name="server_repository_error_unsupported_schema">/.well-known/nodeinfo did not contain understandable schemas</string>
<string name="server_repository_error_get_node_info">fetching nodeinfo %1$s failed: %2$s</string>
<string name="server_repository_error_validate_node_info">validating nodeinfo %1$s failed: %2$s</string>
<string name="server_repository_error_get_instance_info">fetching /api/v1/instance failed: %1$s</string>
<string name="server_repository_error_capabilities">parsing server capabilities failed: %1$s</string>
<string name="pref_title_update_check_now">Check for update now</string>
<string name="pref_update_check_no_updates">There are no updates available</string>
<string name="pref_update_next_scheduled_check">Next scheduled check: %1$s</string>

View File

@ -22,6 +22,7 @@ import app.pachli.appstore.EventHub
import app.pachli.components.timeline.FilterKind
import app.pachli.components.timeline.FiltersRepository
import app.pachli.core.accounts.AccountManager
import app.pachli.core.data.repository.ServerRepository
import app.pachli.core.database.model.AccountEntity
import app.pachli.core.network.model.nodeinfo.UnvalidatedJrd
import app.pachli.core.network.model.nodeinfo.UnvalidatedNodeInfo
@ -30,7 +31,6 @@ import app.pachli.core.network.retrofit.NodeInfoApi
import app.pachli.core.preferences.SharedPreferencesRepository
import app.pachli.core.testing.fakes.InMemorySharedPreferences
import app.pachli.core.testing.rules.MainCoroutineRule
import app.pachli.network.ServerRepository
import app.pachli.settings.AccountPreferenceDataStore
import app.pachli.usecase.TimelineCases
import app.pachli.util.StatusDisplayOptionsRepository

View File

@ -15,23 +15,23 @@
* see <http://www.gnu.org/licenses>.
*/
package app.pachli.network
package app.pachli.core.data.repository
import androidx.annotation.StringRes
import app.pachli.R
import app.pachli.core.accounts.AccountManager
import app.pachli.core.common.PachliError
import app.pachli.core.common.di.ApplicationScope
import app.pachli.core.data.R
import app.pachli.core.data.repository.ServerRepository.Error.Capabilities
import app.pachli.core.data.repository.ServerRepository.Error.GetInstanceInfoV1
import app.pachli.core.data.repository.ServerRepository.Error.GetNodeInfo
import app.pachli.core.data.repository.ServerRepository.Error.GetWellKnownNodeInfo
import app.pachli.core.data.repository.ServerRepository.Error.UnsupportedSchema
import app.pachli.core.data.repository.ServerRepository.Error.ValidateNodeInfo
import app.pachli.core.network.Server
import app.pachli.core.network.model.nodeinfo.NodeInfo
import app.pachli.core.network.retrofit.MastodonApi
import app.pachli.core.network.retrofit.NodeInfoApi
import app.pachli.network.ServerRepository.Error.Capabilities
import app.pachli.network.ServerRepository.Error.GetInstanceInfoV1
import app.pachli.network.ServerRepository.Error.GetNodeInfo
import app.pachli.network.ServerRepository.Error.GetWellKnownNodeInfo
import app.pachli.network.ServerRepository.Error.UnsupportedSchema
import app.pachli.network.ServerRepository.Error.ValidateNodeInfo
import at.connyduck.calladapter.networkresult.fold
import com.github.michaelbull.result.Err
import com.github.michaelbull.result.Ok

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="server_repository_error_get_well_known_node_info">fallo al obtener /.well-known/nodeinfo: %1$s</string>
<string name="server_repository_error_unsupported_schema">/.well-known/nodeinfo no contiene esquemas comprensibles</string>
<string name="server_repository_error_get_node_info">fallo al obtener nodeinfo %1$s: %2$s</string>
<string name="server_repository_error_validate_node_info">fallo al validar nodeinfo %1$s: %2$s</string>
<string name="server_repository_error_get_instance_info">fallo al obtener /api/v1/instance: %1$s</string>
<string name="server_repository_error_capabilities">fallo al analizar las capacidades del servidor: %1$s</string>
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="server_repository_error_get_well_known_node_info">haku /.well-known/nodeinfo epäonnistui: %1$s</string>
<string name="server_repository_error_unsupported_schema">/.well-known/nodeinfo ei sisältänyt ymmärrettäviä kaavoja</string>
<string name="server_repository_error_get_node_info">solmun tietojen haku osoitteesta %1$s epäonnistui: %2$s</string>
<string name="server_repository_error_validate_node_info">solmun %1$s tietojen validointi epäonnistui: %2$s</string>
<string name="server_repository_error_get_instance_info">haku /api/v1/instance epäonnistui: %1$s</string>
<string name="server_repository_error_capabilities">palvelimen tietojen jäsentely epäonnistui: %1$s</string>
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="server_repository_error_get_well_known_node_info">ophalen /.well-known/nodeinfo mislukt: %1$s</string>
<string name="server_repository_error_unsupported_schema">/.well-known/nodeinfo bevatte geen begrijpbare schemas</string>
<string name="server_repository_error_get_node_info">ophalen nodeinfo %1$s mislukt: %2$s</string>
<string name="server_repository_error_validate_node_info">valideren van nodeinfo %1$s mislukt: %2$s</string>
<string name="server_repository_error_get_instance_info">ophalen van /api/v1/instance mislukt: %1$s</string>
<string name="server_repository_error_capabilities">verwerken van server mogelijkheden mislukt: %1$s</string>
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="server_repository_error_get_well_known_node_info">misslyckades med att hämta /.well-known/nodeinfo: %1$s</string>
<string name="server_repository_error_unsupported_schema">/.well-known/nodeinfo innehöll inte begripliga scheman</string>
<string name="server_repository_error_get_node_info">hämtning av nodeinfo %1$s misslyckades: %2$s</string>
<string name="server_repository_error_validate_node_info">validering av nodeinfo %1$s misslyckades: %2$s</string>
<string name="server_repository_error_get_instance_info">hämtning av /api/v1/instance misslyckades: %1$s</string>
<string name="server_repository_error_capabilities">tolkning av serverfunktioner misslyckades: %1$s</string>
</resources>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="server_repository_error_get_well_known_node_info">fetching /.well-known/nodeinfo failed: %1$s</string>
<string name="server_repository_error_unsupported_schema">/.well-known/nodeinfo did not contain understandable schemas</string>
<string name="server_repository_error_get_node_info">fetching nodeinfo %1$s failed: %2$s</string>
<string name="server_repository_error_validate_node_info">validating nodeinfo %1$s failed: %2$s</string>
<string name="server_repository_error_get_instance_info">fetching /api/v1/instance failed: %1$s</string>
<string name="server_repository_error_capabilities">parsing server capabilities failed: %1$s</string>
</resources>