-
Notifications
You must be signed in to change notification settings - Fork 0
fix: 로그인 필요 기능 진입 시 다이얼로그 노출하도록 수정 #217
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
90cdc8b
[BOOK-420] refactor: 에러 전용 이벤트/다이얼로그 스펙을 범용 이벤트 구조로 확장
seoyoon513 8c29fbe
[BOOK-420] refactor: Move postErrorDialog to DialogEvents
seoyoon513 8be56c3
[BOOK-420] feat: 토스트 및 로그인 화면 이동 로직을 공통 다이얼로그 이벤트로 변경
seoyoon513 4d50515
[BOOK-420] chore: code style check success
seoyoon513 cafd74c
[BOOK-420] refactor: DialogSpec을 constants -> event 패키지로 이동
seoyoon513 82e4da2
[BOOK-420] refactor: ReedEvent.ShowDialog에서 불필요한 key 제거
seoyoon513 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
10 changes: 0 additions & 10 deletions
10
core/common/src/main/kotlin/com/ninecraft/booket/core/common/constants/ErrorDialogSpec.kt
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
core/common/src/main/kotlin/com/ninecraft/booket/core/common/event/DialogEvents.kt
This file contains hidden or 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,58 @@ | ||
| package com.ninecraft.booket.core.common.event | ||
|
|
||
| import com.ninecraft.booket.core.common.constants.ErrorScope | ||
| import com.ninecraft.booket.core.common.utils.isNetworkError | ||
| import retrofit2.HttpException | ||
|
|
||
| fun postErrorDialog( | ||
| errorScope: ErrorScope, | ||
| exception: Throwable, | ||
| confirmLabel: String = "확인", | ||
| onConfirm: () -> Unit = {}, | ||
| ) { | ||
| val (title, message) = when { | ||
| exception.isNetworkError() -> { | ||
| null to "네트워크 연결이 불안정합니다.\n인터넷 연결을 확인해주세요" | ||
| } | ||
|
|
||
| exception is HttpException -> { | ||
| when (errorScope) { | ||
| ErrorScope.GLOBAL -> { | ||
| null to "알 수 없는 문제가 발생했어요.\n다시 시도해주세요" | ||
| } | ||
|
|
||
| ErrorScope.LOGIN -> { | ||
| "로그인 오류" to "예기치 않은 오류가 발생했습니다.\n다시 로그인 해주세요." | ||
| } | ||
|
|
||
| ErrorScope.AUTH_SESSION_EXPIRED -> { | ||
| null to "세션이 만료되었어요.\n다시 로그인 해주세요" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| else -> { | ||
| null to "알 수 없는 문제가 발생했어요.\n다시 시도해주세요" | ||
| } | ||
| } | ||
|
|
||
| val spec = DialogSpec( | ||
| title = title, | ||
| message = message, | ||
| confirmLabel = confirmLabel, | ||
| onConfirm = onConfirm, | ||
| ) | ||
|
|
||
| EventHelper.sendEvent(event = ReedEvent.ShowDialog(spec)) | ||
| } | ||
|
|
||
| fun postLoginRequiredDialog(onConfirm: () -> Unit) { | ||
| val spec = DialogSpec( | ||
| message = "로그인이 필요한 기능입니다.\n로그인 해주세요.", | ||
| confirmLabel = "로그인 하기", | ||
| onConfirm = onConfirm, | ||
| dismissLabel = "닫기", | ||
| ) | ||
|
|
||
| EventHelper.sendEvent(event = ReedEvent.ShowDialog(spec)) | ||
| } |
10 changes: 10 additions & 0 deletions
10
core/common/src/main/kotlin/com/ninecraft/booket/core/common/event/DialogSpec.kt
This file contains hidden or 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.ninecraft.booket.core.common.event | ||
|
|
||
| data class DialogSpec( | ||
| val message: String, | ||
| val confirmLabel: String, | ||
| val onConfirm: () -> Unit, | ||
| val title: String? = null, | ||
| val dismissLabel: String? = null, | ||
| val onDismissRequest: () -> Unit = {}, | ||
| ) |
22 changes: 0 additions & 22 deletions
22
core/common/src/main/kotlin/com/ninecraft/booket/core/common/event/ErrorEventHelper.kt
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
core/common/src/main/kotlin/com/ninecraft/booket/core/common/event/EventHelper.kt
This file contains hidden or 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,17 @@ | ||
| package com.ninecraft.booket.core.common.event | ||
|
|
||
| import kotlinx.coroutines.channels.Channel | ||
| import kotlinx.coroutines.flow.receiveAsFlow | ||
|
|
||
| object EventHelper { | ||
| private val _eventFlow = Channel<ReedEvent>(Channel.BUFFERED) | ||
| val eventFlow = _eventFlow.receiveAsFlow() | ||
|
|
||
| fun sendEvent(event: ReedEvent) { | ||
| _eventFlow.trySend(event) | ||
| } | ||
| } | ||
|
|
||
| sealed interface ReedEvent { | ||
| data class ShowDialog(val spec: DialogSpec) : ReedEvent | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
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.
이벤트 전송 실패 처리가 누락되었습니다.
trySend()는 채널이 닫혔거나 버퍼가 가득 찬 경우 실패할 수 있지만, 반환된 결과를 확인하지 않아 이벤트가 조용히 손실될 수 있습니다. 로그인 요청 다이얼로그와 같은 중요한 이벤트가 사용자에게 표시되지 않을 수 있습니다.다음 diff를 적용하여 실패한 전송을 처리하세요:
fun sendEvent(event: ReedEvent) { - _eventFlow.trySend(event) + _eventFlow.trySend(event).onFailure { + // 실패 시 로깅 또는 대체 처리 + android.util.Log.e("EventHelper", "Failed to send event: $event", it) + } }또는 suspend 함수로 변경하여 확실한 전송을 보장할 수도 있습니다:
🤖 Prompt for AI Agents