diff --git a/modules/api/src/main/java/net/pantasystem/milktea/api/milktea/instance/ticker/InstanceTickerAPIService.kt b/modules/api/src/main/java/net/pantasystem/milktea/api/milktea/instance/ticker/InstanceTickerAPIService.kt index c6819ff7a0..37639449ba 100644 --- a/modules/api/src/main/java/net/pantasystem/milktea/api/milktea/instance/ticker/InstanceTickerAPIService.kt +++ b/modules/api/src/main/java/net/pantasystem/milktea/api/milktea/instance/ticker/InstanceTickerAPIService.kt @@ -1,5 +1,6 @@ package net.pantasystem.milktea.api.milktea.instance.ticker +import net.pantasystem.milktea.api.misskey.infos.SimpleInstanceInfo import retrofit2.Response import retrofit2.http.GET import retrofit2.http.Query @@ -8,4 +9,11 @@ interface InstanceTickerAPIService { @GET("/instances") suspend fun getInstanceInfo(@Query("host") host: String): Response + + @GET("instances-search") + suspend fun getInstances( + @Query("query") name: String? = null, + @Query("limit") limit: Int? = null, + @Query("offset") offset: Int? = null, + ): Response> } \ No newline at end of file diff --git a/modules/api/src/main/java/net/pantasystem/milktea/api/misskey/infos/SimpleInstanceInfo.kt b/modules/api/src/main/java/net/pantasystem/milktea/api/misskey/infos/SimpleInstanceInfo.kt index 56b866aedb..73b8f59f7c 100644 --- a/modules/api/src/main/java/net/pantasystem/milktea/api/misskey/infos/SimpleInstanceInfo.kt +++ b/modules/api/src/main/java/net/pantasystem/milktea/api/misskey/infos/SimpleInstanceInfo.kt @@ -5,8 +5,8 @@ import kotlinx.serialization.Serializable @Serializable data class SimpleInstanceInfo( - @SerialName("url") val url: String, - @SerialName("name") val name: String, + @SerialName("uri") val url: String, + @SerialName("name") val name: String? = null, @SerialName("description") val description: String? = null, @SerialName("iconUrl") val iconUrl: String? = null, ) \ No newline at end of file diff --git a/modules/features/auth/src/main/java/net/pantasystem/milktea/auth/InstanceInfoCard.kt b/modules/features/auth/src/main/java/net/pantasystem/milktea/auth/InstanceInfoCard.kt index 4d89318b5e..61e3169dfd 100644 --- a/modules/features/auth/src/main/java/net/pantasystem/milktea/auth/InstanceInfoCard.kt +++ b/modules/features/auth/src/main/java/net/pantasystem/milktea/auth/InstanceInfoCard.kt @@ -56,7 +56,7 @@ fun MisskeyInstanceInfoCard( Modifier.weight(1f) ) { Text( - info.name, + info.name ?: info.url, fontSize = 18.sp, maxLines = 1, overflow = TextOverflow.Ellipsis diff --git a/modules/features/auth/src/main/java/net/pantasystem/milktea/auth/suggestions/InstanceSuggestionsPagingModel.kt b/modules/features/auth/src/main/java/net/pantasystem/milktea/auth/suggestions/InstanceSuggestionsPagingModel.kt index 38a3fa2ae9..9a73d85d34 100644 --- a/modules/features/auth/src/main/java/net/pantasystem/milktea/auth/suggestions/InstanceSuggestionsPagingModel.kt +++ b/modules/features/auth/src/main/java/net/pantasystem/milktea/auth/suggestions/InstanceSuggestionsPagingModel.kt @@ -1,6 +1,5 @@ package net.pantasystem.milktea.auth.suggestions -import androidx.compose.ui.text.intl.Locale import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.flow.Flow @@ -8,7 +7,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import net.pantasystem.milktea.api.misskey.InstanceInfoAPIBuilder +import net.pantasystem.milktea.api.milktea.instance.ticker.InstanceTickerAPIServiceBuilder import net.pantasystem.milktea.api.misskey.infos.SimpleInstanceInfo import net.pantasystem.milktea.common.Logger import net.pantasystem.milktea.common.PageableState @@ -22,7 +21,7 @@ import net.pantasystem.milktea.common.throwIfHasError import javax.inject.Inject class InstanceSuggestionsPagingModel @Inject constructor( - private val instancesInfoAPIBuilder: InstanceInfoAPIBuilder, + private val instanceTickerAPIBuilder: InstanceTickerAPIServiceBuilder, private val loggerFactory: Logger.Factory, ) : StateLocker, PaginationState, @@ -56,10 +55,10 @@ class InstanceSuggestionsPagingModel @Inject constructor( override suspend fun loadPrevious(): Result> = runCancellableCatching { - instancesInfoAPIBuilder.build().getInstances( + instanceTickerAPIBuilder.build("https://milktea-instance-ticker.milktea.workers.dev/").getInstances( offset = _offset, name = _name, - lang = Locale.current.language, +// lang = Locale.current.language, ).throwIfHasError().body()!!.also { _offset += it.size }