-
Notifications
You must be signed in to change notification settings - Fork 8
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/USER] 디자인 수정 및 Domain Exception 추가 (#978) #979
Changes from 6 commits
fde0dd2
54d939a
5df80f6
d671daa
5d3bb0d
7c47f46
5eb5848
7a4ff51
b417b7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.festago.festago.domain.exception | ||
|
||
object BookmarkLimitExceededException : Exception() { | ||
private fun readResolve(): Any = BookmarkLimitExceededException | ||
} | ||
|
||
fun Throwable.isBookmarkLimitExceeded() = this is BookmarkLimitExceededException |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.festago.festago.domain.exception | ||
|
||
object NetworkException : Exception() { | ||
private fun readResolve(): Any = NetworkException | ||
} | ||
|
||
fun Throwable.isNetworkError() = this is NetworkException |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.viewModelScope | ||
import com.festago.festago.common.analytics.AnalyticsHelper | ||
import com.festago.festago.common.analytics.logNetworkFailure | ||
import com.festago.festago.domain.exception.isBookmarkLimitExceeded | ||
import com.festago.festago.domain.exception.isNetworkError | ||
import com.festago.festago.domain.exception.isUnauthorized | ||
import com.festago.festago.domain.model.bookmark.BookmarkType | ||
import com.festago.festago.domain.model.festival.FestivalsPage | ||
import com.festago.festago.domain.repository.ArtistRepository | ||
|
@@ -108,26 +111,31 @@ class ArtistDetailViewModel @Inject constructor( | |
viewModelScope.launch { | ||
val uiState = uiState.value as? ArtistDetailUiState.Success ?: return@launch | ||
|
||
if (!userRepository.isSigned()) { | ||
_event.emit(BookmarkFailure("로그인이 필요합니다")) | ||
return@launch | ||
} | ||
|
||
if (uiState.bookMarked) { | ||
_uiState.value = uiState.copy(bookMarked = false) | ||
bookmarkRepository.deleteArtistBookmark(artistId.toLong()) | ||
.onSuccess { _event.emit(BookmarkSuccess(false)) } | ||
.onFailure { | ||
_uiState.value = uiState.copy(bookMarked = true) | ||
_event.emit(BookmarkFailure("북마크를 해제할 수 없습니다. 인터넷 연결을 확인해주세요")) | ||
if (it.isUnauthorized()) { | ||
_event.emit(BookmarkFailure("로그인이 필요해요")) | ||
} | ||
if (it.isNetworkError()) { | ||
_uiState.value = uiState.copy(bookMarked = true) | ||
_event.emit(BookmarkFailure("북마크를 해제할 수 없습니다. 인터넷 연결을 확인해주세요")) | ||
} | ||
} | ||
} else { | ||
_uiState.value = uiState.copy(bookMarked = true) | ||
bookmarkRepository.addArtistBookmark(artistId.toLong()) | ||
.onSuccess { _event.emit(BookmarkSuccess(true)) } | ||
.onFailure { | ||
_uiState.value = uiState.copy(bookMarked = false) | ||
_event.emit(BookmarkFailure("다른 북마크를 해제하거나 인터넷 연결을 확인해주세요")) | ||
if (it.isUnauthorized()) { | ||
_event.emit(BookmarkFailure("로그인이 필요해요")) | ||
} | ||
if (it.isBookmarkLimitExceeded()) { | ||
_uiState.value = uiState.copy(bookMarked = false) | ||
_event.emit(BookmarkFailure("북마크는 12개까지 가능해요")) | ||
} | ||
Comment on lines
+132
to
+138
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 북마크 할 때도 isNetworkError 처리할 수 있을까요? 북마크 시에는 인터넷 연결이 끊겨도 문제 없이 북마크 되는 것처럼 보입니다. (실제로 북마크 처리 되는 건 아니지만..) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반영했습니다! 추가로 인터넷 문구가 너무 긴거 같아서 "인터넷 연결을 확인해주세요"으로 변경했습니다! 어떠신가요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 굿굿 |
||
} | ||
} | ||
} | ||
|
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.
readResolve() 어디에 쓰이는 걸까요??
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.
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.
아직 담고 있는 변수가 없어서 object로 바꿧는데 워닝 피하는 용도로 사용했습니다! 자세한 내용은 찾아서 올리겠습니다!
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.
Exception 이 클래스라서 상속받은 것도 클래스인게 일반적이지 않을까요?
메세지랑 상관없이 싱글톤으로 존재하지 않아도 될 것 같아요..!