add /user/{uid} call on web module.

- fix some bug with use Pair
This commit is contained in:
dalbodeule 2024-08-04 18:51:41 +09:00
parent b77a3d02c5
commit 4025cbceec
No known key found for this signature in database
GPG Key ID: EFA860D069C9FA65

View File

@ -30,7 +30,6 @@ object Connector {
private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java) private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
fun getChannel(channelId: String): ChzzkChannel? = chzzk.getChannel(channelId) fun getChannel(channelId: String): ChzzkChannel? = chzzk.getChannel(channelId)
fun getChannelAndUser(channelId: String): Pair<ChzzkChannel, User?>? = pair(chzzk.getChannel(channelId), UserService.getUser(channelId))
init { init {
@ -38,17 +37,22 @@ object Connector {
dispatcher.subscribe(GetUserEvents::class) { dispatcher.subscribe(GetUserEvents::class) {
if (it.type == GetUserType.REQUEST) { if (it.type == GetUserType.REQUEST) {
CoroutineScope(Dispatchers.Default).launch { CoroutineScope(Dispatchers.Default).launch {
val channel = getChannelAndUser(it.uid ?: "") val channel = getChannel(it.uid ?: "")
if(channel == null) dispatcher.post(GetUserEvents( if(channel == null) dispatcher.post(GetUserEvents(
GetUserType.NOTFOUND, null, null, null, null GetUserType.NOTFOUND, null, null, null, null
)) ))
else dispatcher.post(GetUserEvents( else {
GetUserType.RESPONSE, val user = UserService.getUser(channel.channelId)
channel.first.channelId, dispatcher.post(
channel.first.channelName, GetUserEvents(
LiveStatusService.getLiveStatus(channel.second!!)?.status ?: false, GetUserType.RESPONSE,
channel.first.channelImageUrl channel.channelId,
)) channel.channelName,
LiveStatusService.getLiveStatus(user!!)?.status ?: false,
channel.channelImageUrl
)
)
}
} }
} }
} }