-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AN] refactor: 채팅 리팩터링 #361
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6e5c235
fix: 불필요한 더미데이터 금지
gaeun5744 d7a7a0b
Merge branch 'develop' of github.com:woowacourse-teams/2024-friendogl…
gaeun5744 a214344
Merge branch 'develop' of github.com:woowacourse-teams/2024-friendogl…
gaeun5744 4d95f3f
feat: 채팅 dataSource 및 useCase 구현
gaeun5744 51cc8b0
feat: 채팅 유저 리스트 api 연결
gaeun5744 7d52d89
feat: url이 없을 경우, 기본 이미지가 보이도록 구현
gaeun5744 0be0c67
feat: 내 채팅, 남의 채팅 구분하여 뷰가 보이도록 수정
gaeun5744 c2d8b70
refactor: 웹소켓 useCase 적용
gaeun5744 9479b51
rename: invite -> enter로 네이밍 수정
gaeun5744 2fdb152
feat: 유저 프로필 클릭시, 프로필 상세 뷰로 이동 구현
gaeun5744 c60d82a
style: ktlint 적용
gaeun5744 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 5 additions & 9 deletions
14
android/app/src/main/java/com/happy/friendogly/data/repository/ChatRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
package com.happy.friendogly.data.repository | ||
|
||
import com.happy.friendogly.data.mapper.toDomain | ||
import com.happy.friendogly.data.source.ChatDataSource | ||
import com.happy.friendogly.domain.model.ChatMember | ||
import com.happy.friendogly.domain.model.ChatRooms | ||
import com.happy.friendogly.domain.repository.ChatRepository | ||
import com.happy.friendogly.remote.api.ChatService | ||
import com.happy.friendogly.remote.mapper.toData | ||
|
||
class ChatRepositoryImpl(private val service: ChatService) : ChatRepository { | ||
override suspend fun getChatList(): Result<ChatRooms> = | ||
runCatching { | ||
service.getChatList().data.toData().toDomain() | ||
} | ||
class ChatRepositoryImpl(private val source: ChatDataSource) : ChatRepository { | ||
override suspend fun getChatList(): Result<ChatRooms> = source.getChatList().mapCatching { it.toDomain() } | ||
|
||
override suspend fun getMembers(chatRoomId: Long): Result<List<ChatMember>> = | ||
runCatching { | ||
service.getChatMembers(chatRoomId).data.map { it.toData() }.map { it.toDomain() } | ||
source.getMembers(chatRoomId).mapCatching { member -> | ||
member.map { it.toDomain() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
android/app/src/main/java/com/happy/friendogly/data/source/ChatDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.happy.friendogly.data.source | ||
|
||
import com.happy.friendogly.data.model.ChatMemberDto | ||
import com.happy.friendogly.data.model.ChatRoomListDto | ||
|
||
interface ChatDataSource { | ||
suspend fun getChatList(): Result<ChatRoomListDto> | ||
|
||
suspend fun getMembers(chatRoomId: Long): Result<List<ChatMemberDto>> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
android/app/src/main/java/com/happy/friendogly/domain/usecase/GetChatListUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.happy.friendogly.domain.usecase | ||
|
||
import com.happy.friendogly.domain.model.ChatRooms | ||
import com.happy.friendogly.domain.repository.ChatRepository | ||
|
||
class GetChatListUseCase( | ||
val repository: ChatRepository, | ||
) { | ||
suspend operator fun invoke(): Result<ChatRooms> = repository.getChatList() | ||
} |
10 changes: 10 additions & 0 deletions
10
android/app/src/main/java/com/happy/friendogly/domain/usecase/GetChatMemberUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.happy.friendogly.domain.usecase | ||
|
||
import com.happy.friendogly.domain.model.ChatMember | ||
import com.happy.friendogly.domain.repository.ChatRepository | ||
|
||
class GetChatMemberUseCase( | ||
val repository: ChatRepository, | ||
) { | ||
suspend operator fun invoke(chatRoomId: Long): Result<List<ChatMember>> = repository.getMembers(chatRoomId) | ||
} |
9 changes: 9 additions & 0 deletions
9
android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishEnterUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.happy.friendogly.domain.usecase | ||
|
||
import com.happy.friendogly.domain.repository.WebSocketRepository | ||
|
||
class PublishEnterUseCase( | ||
private val repository: WebSocketRepository, | ||
) { | ||
suspend operator fun invoke(chatRoomId: Long): Result<Unit> = repository.publishEnter(chatRoomId) | ||
} |
9 changes: 9 additions & 0 deletions
9
android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishLeaveUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.happy.friendogly.domain.usecase | ||
|
||
import com.happy.friendogly.domain.repository.WebSocketRepository | ||
|
||
class PublishLeaveUseCase( | ||
private val repository: WebSocketRepository, | ||
) { | ||
suspend operator fun invoke(chatRoomId: Long): Result<Unit> = repository.publishLeave(chatRoomId) | ||
} |
12 changes: 12 additions & 0 deletions
12
android/app/src/main/java/com/happy/friendogly/domain/usecase/PublishSendMessageUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.happy.friendogly.domain.usecase | ||
|
||
import com.happy.friendogly.domain.repository.WebSocketRepository | ||
|
||
class PublishSendMessageUseCase( | ||
private val repository: WebSocketRepository, | ||
) { | ||
suspend operator fun invoke( | ||
chatRoomId: Long, | ||
content: String, | ||
): Result<Unit> = repository.publishSend(chatRoomId, content) | ||
} |
12 changes: 12 additions & 0 deletions
12
android/app/src/main/java/com/happy/friendogly/domain/usecase/SubScribeMessageUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.happy.friendogly.domain.usecase | ||
|
||
import com.happy.friendogly.domain.model.ChatComponent | ||
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<ChatComponent> = repository.subscribeMessage(chatRoomId, myMemberId) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getChatListUseCase()
이렇게 써도 좋을 것 같아요~~