Skip to content

Commit

Permalink
fix : api 변경사항 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Feb 2, 2025
1 parent ce5b5a6 commit d18a20b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class PopupDataSource @Inject constructor(
) {
private val dataStore = context.dataStore

suspend fun getPopup(): PopupResponse = service.getPopup()
suspend fun getPopup(view: String): PopupResponse = service.getPopup(view)

fun shouldShowEvent(id: String): Flow<Boolean> = dataStore.data.map {
LocalDate.now() > (it.dateHidingEvent?.get(id)?.toLocalDate() ?: LocalDate.MIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package com.nexters.boolti.data.network.api

import com.nexters.boolti.data.network.response.PopupResponse
import retrofit2.http.GET
import retrofit2.http.Path

internal interface PopupService {
@GET("/app/papi/v1/popup")
suspend fun getPopup(): PopupResponse
@GET("/app/papi/v1/popup/{view}")
suspend fun getPopup(@Path("view") view: String): PopupResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class PopupRepositoryImpl @Inject constructor(
dataSource.hideEventToday(id)
}

override fun getPopup() = flow {
emit(dataSource.getPopup().toDomain())
override fun getPopup(view: String) = flow {
emit(dataSource.getPopup(view).toDomain())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import kotlinx.coroutines.flow.Flow
interface PopupRepository {
fun shouldShowEvent(id: String): Flow<Boolean>
fun hideEventToday(id: String): Flow<Unit>
fun getPopup(): Flow<Popup>
fun getPopup(view: String): Flow<Popup>
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import javax.inject.Singleton
class GetPopupUseCase @Inject constructor(
private val popupRepository: PopupRepository,
) {
operator fun invoke(): Flow<Popup> = popupRepository
.getPopup()
operator fun invoke(view: String): Flow<Popup> = popupRepository
.getPopup(view)
.filter { popup ->
popup is Popup.Notice || popupRepository.shouldShowEvent(popup.id).first()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ShowViewModel @Inject constructor(
}

private fun fetchPopup() {
getPopupUseCase()
getPopupUseCase("HOME")
.onEach { popup -> sendEvent(ShowEvent.ShowPopup(popup)) }
.launchIn(viewModelScope + recordExceptionHandler)
}
Expand Down

0 comments on commit d18a20b

Please sign in to comment.