-
Notifications
You must be signed in to change notification settings - Fork 0
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
Enhancement: 시스템 앱 알림 화면 전환 외 #229
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
87c4d30
enhancement: 알림 설정 클릭 시 시스템 앱 알림 설정 화면으로 전환
LeeHaiLim 8c660a7
enhancement: flow 내에서 예외처리 할 수 있도록 코드 변경
LeeHaiLim 39142eb
chore: 사용하지 않는 메서드 제거
LeeHaiLim 5207666
feat: 데이터 레이어 예외 처리
LeeHaiLim f6b10a4
chore: 패키지 이름 변경
LeeHaiLim b939a78
refactor: 뷰홀더 분리
LeeHaiLim 7ff44a2
refactor: comparator 로직 가독성 개선
LeeHaiLim 8cae396
feat: 서버 실패 시 무조건 로컬 데이터 가져오도록 변경
LeeHaiLim 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
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
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 |
---|---|---|
|
@@ -14,30 +14,42 @@ import com.teameetmeet.meetmeet.util.date.DateTimeFormat | |
import com.teameetmeet.meetmeet.util.date.toDateString | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.catch | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.flow.map | ||
import kotlinx.coroutines.flow.onEach | ||
import java.time.ZoneId | ||
import javax.inject.Inject | ||
|
||
class CalendarRepository @Inject constructor( | ||
private val localCalendarDataSource: LocalCalendarDataSource, | ||
private val remoteCalendarDataSource: RemoteCalendarDataSource | ||
) { | ||
suspend fun getEvents(startDate: Long, endDate: Long): Flow<List<Event>> { | ||
try { | ||
syncEvents(startDate, endDate) | ||
} finally { | ||
return localCalendarDataSource.getEvents(startDate, endDate) | ||
} | ||
fun getSyncedEvents(startDateTime: Long, endDateTime: Long): Flow<List<Event>> { | ||
return remoteCalendarDataSource | ||
.getEvents( | ||
startDateTime.toDateString(DateTimeFormat.ISO_DATE_TIME, ZoneId.of("UTC")), | ||
endDateTime.toDateString(DateTimeFormat.ISO_DATE_TIME, ZoneId.of("UTC")) | ||
).onEach { | ||
localCalendarDataSource.deleteEvents(startDateTime, endDateTime) | ||
localCalendarDataSource.insertEvents(it.map(EventResponse::toEvent)) | ||
}.map { | ||
localCalendarDataSource.getEvents(startDateTime, endDateTime).first() | ||
}.catch { | ||
emit(localCalendarDataSource.getEvents(startDateTime, endDateTime).first()) | ||
} | ||
Comment on lines
+27
to
+39
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. catch에서 emit하는 방법 좋습니다! 👍👍 |
||
} | ||
|
||
fun getEventsByUserId(userId: Int, startDate: Long, endDate: Long): Flow<List<Event>> { | ||
return remoteCalendarDataSource.getEventsByUserId( | ||
userId, | ||
startDate.toDateString(DateTimeFormat.ISO_DATE_TIME, ZoneId.of("UTC")), | ||
endDate.toDateString(DateTimeFormat.ISO_DATE_TIME, ZoneId.of("UTC")) | ||
).map { | ||
it.map(UserEventResponse::toEvent) | ||
} | ||
fun getEventsByUserId(userId: Int, startDateTime: Long, endDateTime: Long): Flow<List<Event>> { | ||
return remoteCalendarDataSource | ||
.getEventsByUserId( | ||
userId, | ||
startDateTime.toDateString(DateTimeFormat.ISO_DATE_TIME, ZoneId.of("UTC")), | ||
endDateTime.toDateString(DateTimeFormat.ISO_DATE_TIME, ZoneId.of("UTC")) | ||
).map { | ||
it.map(UserEventResponse::toEvent) | ||
}.catch { | ||
throw it.toException() | ||
} | ||
} | ||
|
||
suspend fun deleteEvents() { | ||
|
@@ -82,19 +94,8 @@ class CalendarRepository @Inject constructor( | |
endDate: String | ||
): Flow<List<EventResponse>> { | ||
return remoteCalendarDataSource.searchEvents(keyword, startDate, endDate) | ||
} | ||
|
||
private suspend fun syncEvents(startDateTime: Long, endDateTime: Long) { | ||
remoteCalendarDataSource | ||
.getEvents( | ||
startDateTime.toDateString(DateTimeFormat.ISO_DATE_TIME, ZoneId.of("UTC")), | ||
endDateTime.toDateString(DateTimeFormat.ISO_DATE_TIME, ZoneId.of("UTC")) | ||
).catch { | ||
//todo: 예외처리 | ||
throw it | ||
}.collect { | ||
localCalendarDataSource.deleteEvents(startDateTime, endDateTime) | ||
localCalendarDataSource.insertEvents(it.map(EventResponse::toEvent)) | ||
.catch { | ||
throw it.toException() | ||
} | ||
} | ||
} |
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
17 changes: 0 additions & 17 deletions
17
android/app/src/main/java/com/teameetmeet/meetmeet/data/repository/SettingRepository.kt
This file was deleted.
Oops, something went wrong.
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.
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.
좋은 방법이네요!!