Skip to content

Commit

Permalink
[REFACTOR] #63 : GetEventsListUseCase -> GetEventListUseCase
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Dec 28, 2023
1 parent 2cc439e commit ed133d1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.wap.wapp.core.model.event.Event
import java.time.LocalDate
import javax.inject.Inject

class GetEventsUseCase @Inject constructor(
class GetEventListUseCase @Inject constructor(
private val eventRepository: EventRepository,
) {
suspend operator fun invoke(date: LocalDate): Result<List<Event>> = runCatching {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.wap.wapp.feature.management
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wap.wapp.core.commmon.util.DateUtil.generateNowDate
import com.wap.wapp.core.domain.usecase.event.GetEventsUseCase
import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase
import com.wap.wapp.core.domain.usecase.management.HasManagerStateUseCase
import com.wap.wapp.core.domain.usecase.survey.GetSurveyListUseCase
import com.wap.wapp.core.model.event.Event
Expand All @@ -22,7 +22,7 @@ import javax.inject.Inject
class ManagementViewModel @Inject constructor(
private val hasManagerStateUseCase: HasManagerStateUseCase,
private val getSurveyListUseCase: GetSurveyListUseCase,
private val getEventsUseCase: GetEventsUseCase,
private val getEventListUseCase: GetEventListUseCase,
) : ViewModel() {

private val _errorFlow: MutableSharedFlow<Throwable> = MutableSharedFlow()
Expand Down Expand Up @@ -67,7 +67,7 @@ class ManagementViewModel @Inject constructor(
private suspend fun getMonthEventList() {
_eventList.value = EventsState.Loading

getEventsUseCase(generateNowDate()).onSuccess { events ->
getEventListUseCase(generateNowDate()).onSuccess { events ->
_eventList.value = EventsState.Success(events)
}.onFailure { exception ->
_errorFlow.emit(exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.wap.wapp.feature.management.registration.survey
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wap.wapp.core.commmon.util.DateUtil
import com.wap.wapp.core.domain.usecase.event.GetEventsUseCase
import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase
import com.wap.wapp.core.domain.usecase.management.RegisterSurveyUseCase
import com.wap.wapp.core.model.event.Event
import com.wap.wapp.core.model.survey.QuestionType
Expand All @@ -21,7 +21,7 @@ import javax.inject.Inject
@HiltViewModel
class SurveyRegistrationViewModel @Inject constructor(
private val registerSurveyUseCase: RegisterSurveyUseCase,
private val getEventsUseCase: GetEventsUseCase,
private val getEventListUseCase: GetEventListUseCase,
) : ViewModel() {
private val _surveyRegistrationEvent: MutableSharedFlow<SurveyRegistrationEvent> =
MutableSharedFlow()
Expand Down Expand Up @@ -95,7 +95,7 @@ class SurveyRegistrationViewModel @Inject constructor(

fun getEventList() {
viewModelScope.launch {
getEventsUseCase(DateUtil.generateNowDate()).fold(
getEventListUseCase(DateUtil.generateNowDate()).fold(
onSuccess = { eventList ->
_eventList.value = eventList
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.wap.wapp.feature.notice
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wap.wapp.core.commmon.util.DateUtil
import com.wap.wapp.core.domain.usecase.event.GetEventsUseCase
import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase
import com.wap.wapp.core.model.event.Event
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -15,7 +15,7 @@ import javax.inject.Inject

@HiltViewModel
class NoticeViewModel @Inject constructor(
private val getEventsUseCase: GetEventsUseCase,
private val getEventListUseCase: GetEventListUseCase,
) : ViewModel() {

private val _monthEvents = MutableStateFlow<EventsState>(EventsState.Loading)
Expand All @@ -35,7 +35,7 @@ class NoticeViewModel @Inject constructor(
private fun getMonthEvents() {
_monthEvents.value = EventsState.Loading
viewModelScope.launch {
getEventsUseCase(_selectedDate.value).fold(
getEventListUseCase(_selectedDate.value).fold(
onSuccess = { _monthEvents.value = EventsState.Success(it) },
onFailure = { _monthEvents.value = EventsState.Failure(it) },
)
Expand All @@ -45,7 +45,7 @@ class NoticeViewModel @Inject constructor(
fun getSelectedDateEvents() {
_selectedDateEvents.value = EventsState.Loading
viewModelScope.launch {
getEventsUseCase(_selectedDate.value).fold(
getEventListUseCase(_selectedDate.value).fold(
onSuccess = {
_selectedDateEvents.value =
EventsState.Success(it.filter { it.period == _selectedDate.value })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.wap.wapp.feature.profile
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wap.wapp.core.commmon.util.DateUtil
import com.wap.wapp.core.domain.usecase.event.GetEventsUseCase
import com.wap.wapp.core.domain.usecase.event.GetEventListUseCase
import com.wap.wapp.core.model.event.Event
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -14,7 +14,7 @@ import javax.inject.Inject

@HiltViewModel
class ProfileViewModel @Inject constructor(
private val getEventsUseCase: GetEventsUseCase,
private val getEventListUseCase: GetEventListUseCase,
) : ViewModel() {

private val _todayEvents = MutableStateFlow<EventsState>(EventsState.Loading)
Expand All @@ -27,7 +27,7 @@ class ProfileViewModel @Inject constructor(
private fun getTodayDateEvents() {
_todayEvents.value = EventsState.Loading
viewModelScope.launch {
getEventsUseCase(DateUtil.generateNowDate()).fold(
getEventListUseCase(DateUtil.generateNowDate()).fold(
onSuccess = {
_todayEvents.value =
EventsState.Success(it.filter { it.period == DateUtil.generateNowDate() })
Expand Down

0 comments on commit ed133d1

Please sign in to comment.