diff --git a/android/app/src/main/java/com/happy/friendogly/application/di/AppModule.kt b/android/app/src/main/java/com/happy/friendogly/application/di/AppModule.kt index 9dda4e49e..3a330dcb2 100644 --- a/android/app/src/main/java/com/happy/friendogly/application/di/AppModule.kt +++ b/android/app/src/main/java/com/happy/friendogly/application/di/AppModule.kt @@ -132,11 +132,11 @@ class AppModule(context: Context) { private val webSocketService = WebSocketService( client = - RemoteModule.createStumpClient( - baseUrl = baseUrl, - tokenManager = tokenManager, - authenticationListener = authenticationListener, - ), + RemoteModule.createStumpClient( + baseUrl = baseUrl, + tokenManager = tokenManager, + authenticationListener = authenticationListener, + ), tokenManager = tokenManager, baseUrl = websocketUrl, ) @@ -226,7 +226,6 @@ class AppModule(context: Context) { val subScribeMessageUseCase: SubScribeMessageUseCase = SubScribeMessageUseCase(repository = webSocketRepository) - companion object { private var instance: AppModule? = null diff --git a/android/app/src/main/java/com/happy/friendogly/data/repository/ChatRepositoryImpl.kt b/android/app/src/main/java/com/happy/friendogly/data/repository/ChatRepositoryImpl.kt index 7335512c6..49501a983 100644 --- a/android/app/src/main/java/com/happy/friendogly/data/repository/ChatRepositoryImpl.kt +++ b/android/app/src/main/java/com/happy/friendogly/data/repository/ChatRepositoryImpl.kt @@ -7,8 +7,7 @@ import com.happy.friendogly.domain.model.ChatRooms import com.happy.friendogly.domain.repository.ChatRepository class ChatRepositoryImpl(private val source: ChatDataSource) : ChatRepository { - override suspend fun getChatList(): Result = - source.getChatList().mapCatching { it.toDomain() } + override suspend fun getChatList(): Result = source.getChatList().mapCatching { it.toDomain() } override suspend fun getMembers(chatRoomId: Long): Result> = source.getMembers(chatRoomId).mapCatching { member -> diff --git a/android/app/src/main/java/com/happy/friendogly/data/repository/WebSocketRepositoryImpl.kt b/android/app/src/main/java/com/happy/friendogly/data/repository/WebSocketRepositoryImpl.kt index cb2557f12..e23d19e85 100644 --- a/android/app/src/main/java/com/happy/friendogly/data/repository/WebSocketRepositoryImpl.kt +++ b/android/app/src/main/java/com/happy/friendogly/data/repository/WebSocketRepositoryImpl.kt @@ -21,7 +21,10 @@ class WebSocketRepositoryImpl(private val source: WebSocketDataSource) : WebSock override suspend fun publishLeave(chatRoomId: Long) = source.publishLeave(chatRoomId) - override suspend fun subscribeMessage(chatRoomId: Long, myMemberId: Long): Flow = + override suspend fun subscribeMessage( + chatRoomId: Long, + myMemberId: Long, + ): Flow = source.subscribeMessage(chatRoomId).map { when (it.messageType) { MessageTypeDto.ENTER -> it.toEnter() diff --git a/android/app/src/main/java/com/happy/friendogly/data/source/ChatDataSource.kt b/android/app/src/main/java/com/happy/friendogly/data/source/ChatDataSource.kt index b8999612d..7eda46136 100644 --- a/android/app/src/main/java/com/happy/friendogly/data/source/ChatDataSource.kt +++ b/android/app/src/main/java/com/happy/friendogly/data/source/ChatDataSource.kt @@ -2,11 +2,8 @@ package com.happy.friendogly.data.source import com.happy.friendogly.data.model.ChatMemberDto import com.happy.friendogly.data.model.ChatRoomListDto -import com.happy.friendogly.domain.model.ChatMember -import com.happy.friendogly.domain.model.ChatRooms interface ChatDataSource { - suspend fun getChatList(): Result suspend fun getMembers(chatRoomId: Long): Result> diff --git a/android/app/src/main/java/com/happy/friendogly/data/source/WebSocketDataSource.kt b/android/app/src/main/java/com/happy/friendogly/data/source/WebSocketDataSource.kt index 05a789935..03ad8c275 100644 --- a/android/app/src/main/java/com/happy/friendogly/data/source/WebSocketDataSource.kt +++ b/android/app/src/main/java/com/happy/friendogly/data/source/WebSocketDataSource.kt @@ -4,14 +4,14 @@ import com.happy.friendogly.data.model.MessageDto import kotlinx.coroutines.flow.Flow interface WebSocketDataSource { - suspend fun publishEnter(memberId: Long):Result + suspend fun publishEnter(memberId: Long): Result suspend fun publishSend( chatRoomId: Long, content: String, - ):Result + ): Result - suspend fun publishLeave(chatRoomId: Long):Result + suspend fun publishLeave(chatRoomId: Long): Result suspend fun subscribeMessage(chatRoomId: Long): Flow } diff --git a/android/app/src/main/java/com/happy/friendogly/domain/repository/WebSocketRepository.kt b/android/app/src/main/java/com/happy/friendogly/domain/repository/WebSocketRepository.kt index a78a100cd..56c29a4b3 100644 --- a/android/app/src/main/java/com/happy/friendogly/domain/repository/WebSocketRepository.kt +++ b/android/app/src/main/java/com/happy/friendogly/domain/repository/WebSocketRepository.kt @@ -13,5 +13,8 @@ interface WebSocketRepository { suspend fun publishLeave(chatRoomId: Long): Result - suspend fun subscribeMessage(chatRoomId: Long, myMemberId: Long): Flow + suspend fun subscribeMessage( + chatRoomId: Long, + myMemberId: Long, + ): Flow } diff --git a/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishEnterUseCase.kt b/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishEnterUseCase.kt index e9661f7ff..e23aebb61 100644 --- a/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishEnterUseCase.kt +++ b/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishEnterUseCase.kt @@ -3,8 +3,7 @@ package com.happy.friendogly.domain.usecase import com.happy.friendogly.domain.repository.WebSocketRepository class PublishEnterUseCase( - private val repository: WebSocketRepository + private val repository: WebSocketRepository, ) { - suspend operator fun invoke(chatRoomId: Long): Result = - repository.publishEnter(chatRoomId) + suspend operator fun invoke(chatRoomId: Long): Result = repository.publishEnter(chatRoomId) } diff --git a/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishLeaveUseCase.kt b/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishLeaveUseCase.kt index baf1b4656..0c7362c89 100644 --- a/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishLeaveUseCase.kt +++ b/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishLeaveUseCase.kt @@ -3,7 +3,7 @@ package com.happy.friendogly.domain.usecase import com.happy.friendogly.domain.repository.WebSocketRepository class PublishLeaveUseCase( - private val repository: WebSocketRepository + private val repository: WebSocketRepository, ) { - suspend operator fun invoke(chatRoomId:Long):Result = repository.publishLeave(chatRoomId) + suspend operator fun invoke(chatRoomId: Long): Result = repository.publishLeave(chatRoomId) } diff --git a/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishSendMessageUseCase.kt b/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishSendMessageUseCase.kt index 7c28dbf14..b46ee3d8b 100644 --- a/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishSendMessageUseCase.kt +++ b/android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishSendMessageUseCase.kt @@ -3,8 +3,10 @@ package com.happy.friendogly.domain.usecase import com.happy.friendogly.domain.repository.WebSocketRepository class PublishSendMessageUseCase( - private val repository: WebSocketRepository + private val repository: WebSocketRepository, ) { - suspend operator fun invoke(chatRoomId: Long, content: String): Result = - repository.publishSend(chatRoomId, content) + suspend operator fun invoke( + chatRoomId: Long, + content: String, + ): Result = repository.publishSend(chatRoomId, content) } diff --git a/android/app/src/main/java/com/happy/friendogly/domain/usecase/SubScribeMessageUseCase.kt b/android/app/src/main/java/com/happy/friendogly/domain/usecase/SubScribeMessageUseCase.kt index 0bacec942..a58d3bbc6 100644 --- a/android/app/src/main/java/com/happy/friendogly/domain/usecase/SubScribeMessageUseCase.kt +++ b/android/app/src/main/java/com/happy/friendogly/domain/usecase/SubScribeMessageUseCase.kt @@ -5,6 +5,8 @@ import com.happy.friendogly.domain.repository.WebSocketRepository import kotlinx.coroutines.flow.Flow class SubScribeMessageUseCase(private val repository: WebSocketRepository) { - suspend operator fun invoke(chatRoomId: Long, myMemberId: Long): Flow = - repository.subscribeMessage(chatRoomId, myMemberId) + suspend operator fun invoke( + chatRoomId: Long, + myMemberId: Long, + ): Flow = repository.subscribeMessage(chatRoomId, myMemberId) } diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/ChatListViewModel.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/ChatListViewModel.kt index 317563291..bbdc90257 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/ChatListViewModel.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/ChatListViewModel.kt @@ -4,9 +4,7 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope -import com.happy.friendogly.domain.repository.ChatRepository import com.happy.friendogly.domain.usecase.GetChatListUseCase -import com.happy.friendogly.domain.usecase.GetChatMemberUseCase import com.happy.friendogly.presentation.base.BaseViewModel import com.happy.friendogly.presentation.base.BaseViewModelFactory import com.happy.friendogly.presentation.ui.chatlist.uimodel.ChatListUiModel diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatActivity.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatActivity.kt index fe3e97e90..0789d9bed 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatActivity.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatActivity.kt @@ -11,12 +11,13 @@ import com.happy.friendogly.presentation.ui.chatlist.chat.adapter.ChatAdapter import com.happy.friendogly.presentation.ui.chatlist.chatinfo.ChatInfoSideSheet import com.happy.friendogly.presentation.ui.otherprofile.OtherProfileActivity -class ChatActivity : BaseActivity(R.layout.activity_chat), +class ChatActivity : + BaseActivity(R.layout.activity_chat), ChatNavigationAction { private val viewModel: ChatViewModel by viewModels { ChatViewModel.factory( AppModule.getInstance().subScribeMessageUseCase, - AppModule.getInstance().publishSendUseCase + AppModule.getInstance().publishSendUseCase, ) } private lateinit var adapter: ChatAdapter @@ -39,13 +40,17 @@ class ChatActivity : BaseActivity(R.layout.activity_chat), viewModel.subscribeMessage(chatId, myMemberId) } - private fun clickChatInfo(myMemberId: Long, chatRoomId: Long) { + private fun clickChatInfo( + myMemberId: Long, + chatRoomId: Long, + ) { binding.ibChatSideMenu.setOnClickListener { val chatInfoSideSheet = ChatInfoSideSheet() - chatInfoSideSheet.arguments = ChatInfoSideSheet.getBundle( - myMemberId = myMemberId, - chatRoomId = chatRoomId - ) + chatInfoSideSheet.arguments = + ChatInfoSideSheet.getBundle( + myMemberId = myMemberId, + chatRoomId = chatRoomId, + ) chatInfoSideSheet.show(supportFragmentManager, "") } } @@ -72,11 +77,11 @@ class ChatActivity : BaseActivity(R.layout.activity_chat), } companion object { - private const val INVALID_ID = -1L private const val EXTRA_CHAT_ID = "chatId" private const val EXTRA_MEMBER_ID = "memberId" + fun getIntent( context: Context, chatId: Long, diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatUiModel.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatUiModel.kt index 991a403b0..aed57c931 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatUiModel.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatUiModel.kt @@ -15,6 +15,6 @@ sealed interface ChatUiModel { val profileUrl: String?, val message: String, val time: LocalTime, - val memberId:Long + val memberId: Long, ) : ChatUiModel } diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatViewModel.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatViewModel.kt index a83b8a036..9e311aa03 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatViewModel.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/ChatViewModel.kt @@ -17,7 +17,7 @@ import kotlinx.coroutines.launch class ChatViewModel( private val subScribeMessageUseCase: SubScribeMessageUseCase, - private val publishSendMessageUseCase: PublishSendMessageUseCase + private val publishSendMessageUseCase: PublishSendMessageUseCase, ) : BaseViewModel() { private val _chats: MutableLiveData> = MutableLiveData() val chats: LiveData> get() = _chats @@ -31,7 +31,10 @@ class ChatViewModel( } } - fun subscribeMessage(chatRoomId: Long, myMemberId: Long) { + fun subscribeMessage( + chatRoomId: Long, + myMemberId: Long, + ) { viewModelScope.launch { val newChat = subScribeMessageUseCase(chatRoomId, myMemberId).map { @@ -62,12 +65,12 @@ class ChatViewModel( companion object { fun factory( subScribeMessageUseCase: SubScribeMessageUseCase, - publishSendMessageUseCase: PublishSendMessageUseCase + publishSendMessageUseCase: PublishSendMessageUseCase, ): ViewModelProvider.Factory { return BaseViewModelFactory { _ -> ChatViewModel( subScribeMessageUseCase, - publishSendMessageUseCase + publishSendMessageUseCase, ) } } diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/adapter/ChatAdapter.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/adapter/ChatAdapter.kt index d779c1905..ef6a2fa21 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/adapter/ChatAdapter.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/adapter/ChatAdapter.kt @@ -12,7 +12,7 @@ import com.happy.friendogly.presentation.ui.chatlist.chat.ChatNavigationAction import com.happy.friendogly.presentation.ui.chatlist.chat.ChatUiModel class ChatAdapter( - private val onMemberClick: ChatNavigationAction + private val onMemberClick: ChatNavigationAction, ) : ListAdapter(ChatDiffCallback) { init { setHasStableIds(true) @@ -65,7 +65,8 @@ class ChatAdapter( inflater, parent, false, - ), onMemberClick + ), + onMemberClick, ) else -> error("$viewType 잘못된 viewType이 들어왔습니다") diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/adapter/ChatViewHolder.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/adapter/ChatViewHolder.kt index 8a1c27955..caee86a38 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/adapter/ChatViewHolder.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chat/adapter/ChatViewHolder.kt @@ -40,7 +40,7 @@ class MineViewHolder(val binding: ItemChatMineBinding) : ChatViewHolder(binding. } } -class OtherViewHolder(val binding: ItemChatOtherBinding, val onMemberClick:ChatNavigationAction) : ChatViewHolder(binding.root) { +class OtherViewHolder(val binding: ItemChatOtherBinding, val onMemberClick: ChatNavigationAction) : ChatViewHolder(binding.root) { fun bind(item: ChatUiModel.Other) { binding.tvChatOtherMessage.text = item.message val timeFormatter = diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/ChatInfoSideSheet.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/ChatInfoSideSheet.kt index 59415a404..27dc2e6a0 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/ChatInfoSideSheet.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/ChatInfoSideSheet.kt @@ -12,7 +12,6 @@ import com.google.android.material.snackbar.Snackbar import com.happy.friendogly.R import com.happy.friendogly.application.di.AppModule import com.happy.friendogly.databinding.LayoutChatDrawerBinding -import com.happy.friendogly.presentation.ui.chatlist.chat.ChatActivity import com.happy.friendogly.presentation.ui.chatlist.chat.ChatNavigationAction import com.happy.friendogly.presentation.ui.permission.AlarmPermission @@ -22,15 +21,16 @@ class ChatInfoSideSheet : BottomSheetDialogFragment() { get() = requireNotNull(_binding) { "${this::class.java.simpleName} is null" } private lateinit var adapter: JoinPeopleAdapter - private val alarmPermission: AlarmPermission = AlarmPermission.from(this) { isPermitted -> - if (!isPermitted) { - Snackbar.make( - binding.root, - getString(R.string.chat_setting_alarm_alert), - Snackbar.LENGTH_SHORT, - ).show() + private val alarmPermission: AlarmPermission = + AlarmPermission.from(this) { isPermitted -> + if (!isPermitted) { + Snackbar.make( + binding.root, + getString(R.string.chat_setting_alarm_alert), + Snackbar.LENGTH_SHORT, + ).show() + } } - } private val viewModel: ChatInfoViewModel by viewModels { ChatInfoViewModel.factory(AppModule.getInstance().getChatMemberUseCase) @@ -121,12 +121,14 @@ class ChatInfoSideSheet : BottomSheetDialogFragment() { } companion object { - private const val EXTRA_MEMBER_ID = "myMemberId" private const val EXTRA_CHAT_ROOM_ID = "chatRoomId" private const val INVALID_ID = -1L - fun getBundle(myMemberId: Long, chatRoomId: Long): Bundle { + fun getBundle( + myMemberId: Long, + chatRoomId: Long, + ): Bundle { return Bundle().apply { putLong(EXTRA_MEMBER_ID, myMemberId) putLong(EXTRA_CHAT_ROOM_ID, chatRoomId) diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/ChatInfoViewModel.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/ChatInfoViewModel.kt index 45b79d55f..4491d3f48 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/ChatInfoViewModel.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/ChatInfoViewModel.kt @@ -1,11 +1,9 @@ package com.happy.friendogly.presentation.ui.chatlist.chatinfo -import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope -import androidx.paging.LOG_TAG import com.happy.friendogly.domain.usecase.GetChatMemberUseCase import com.happy.friendogly.presentation.base.BaseViewModel import com.happy.friendogly.presentation.base.BaseViewModelFactory @@ -34,10 +32,11 @@ class ChatInfoViewModel( } fun getClubInfo() { // TODO Api 연결 - _clubInfo.value = ChatInfoUiModel( - dogSize = listOf(DogSize.SMALL), - dogGender = listOf(DogGender.FEMALE), - ) + _clubInfo.value = + ChatInfoUiModel( + dogSize = listOf(DogSize.SMALL), + dogGender = listOf(DogGender.FEMALE), + ) } companion object { diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/JoinPeopleAdapter.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/JoinPeopleAdapter.kt index f49c5356e..f0ad53636 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/JoinPeopleAdapter.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/chatinfo/JoinPeopleAdapter.kt @@ -11,7 +11,7 @@ import com.happy.friendogly.databinding.ItemChatJoinPeopleBinding import com.happy.friendogly.presentation.ui.chatlist.chat.ChatNavigationAction class JoinPeopleAdapter( - private val onMemberClick: ChatNavigationAction + private val onMemberClick: ChatNavigationAction, ) : ListAdapter(ChatInfoDiffCallback) { init { @@ -36,7 +36,7 @@ class JoinPeopleAdapter( class JoinPeopleViewHolder( private val binding: ItemChatJoinPeopleBinding, - private val onClick: ChatNavigationAction + private val onClick: ChatNavigationAction, ) : RecyclerView.ViewHolder(binding.root) { fun bind(item: JoinPeople) { if (item.profileUrl.isNotBlank()) { diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/uimodel/ChatUiMapper.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/uimodel/ChatUiMapper.kt index 340aacf68..a80ce6bac 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/uimodel/ChatUiMapper.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/chatlist/uimodel/ChatUiMapper.kt @@ -33,5 +33,5 @@ fun Message.Other.toUiModel() = message = content, time = dateTime.toLocalTime(), profileUrl = profileUrl, - memberId = memberId + memberId = memberId, ) diff --git a/android/app/src/main/java/com/happy/friendogly/remote/source/ChatDataSourceImpl.kt b/android/app/src/main/java/com/happy/friendogly/remote/source/ChatDataSourceImpl.kt index aa5a63568..5cff771e7 100644 --- a/android/app/src/main/java/com/happy/friendogly/remote/source/ChatDataSourceImpl.kt +++ b/android/app/src/main/java/com/happy/friendogly/remote/source/ChatDataSourceImpl.kt @@ -6,13 +6,14 @@ import com.happy.friendogly.data.source.ChatDataSource import com.happy.friendogly.remote.api.ChatService import com.happy.friendogly.remote.mapper.toData -class ChatDataSourceImpl(private val service:ChatService):ChatDataSource { - override suspend fun getChatList(): Result = runCatching { - service.getChatList().data.toData() - } - - override suspend fun getMembers(chatRoomId: Long): Result> = runCatching { - service.getChatMembers(chatRoomId).body()?.map { it.toData() } ?: emptyList() - } +class ChatDataSourceImpl(private val service: ChatService) : ChatDataSource { + override suspend fun getChatList(): Result = + runCatching { + service.getChatList().data.toData() + } + override suspend fun getMembers(chatRoomId: Long): Result> = + runCatching { + service.getChatMembers(chatRoomId).body()?.map { it.toData() } ?: emptyList() + } } diff --git a/android/app/src/main/java/com/happy/friendogly/remote/source/WebSocketDataSourceImpl.kt b/android/app/src/main/java/com/happy/friendogly/remote/source/WebSocketDataSourceImpl.kt index 2a876b5df..f983e7cd7 100644 --- a/android/app/src/main/java/com/happy/friendogly/remote/source/WebSocketDataSourceImpl.kt +++ b/android/app/src/main/java/com/happy/friendogly/remote/source/WebSocketDataSourceImpl.kt @@ -8,20 +8,20 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map class WebSocketDataSourceImpl(private val service: WebSocketService) : WebSocketDataSource { - override suspend fun publishEnter(chatRoomId: Long): Result = runCatching { - service.publishInvite(chatRoomId) - } + override suspend fun publishEnter(chatRoomId: Long): Result = + runCatching { + service.publishInvite(chatRoomId) + } override suspend fun publishSend( chatRoomId: Long, content: String, - ): Result = runCatching { - service.publishSend(chatRoomId, content) - } + ): Result = + runCatching { + service.publishSend(chatRoomId, content) + } - override suspend fun publishLeave(chatRoomId: Long): Result = - runCatching { service.publishLeave(chatRoomId) } + override suspend fun publishLeave(chatRoomId: Long): Result = runCatching { service.publishLeave(chatRoomId) } - override suspend fun subscribeMessage(chatRoomId: Long): Flow = - service.subscribeMessage(chatRoomId).map { it.toData() } + override suspend fun subscribeMessage(chatRoomId: Long): Flow = service.subscribeMessage(chatRoomId).map { it.toData() } }