Skip to content

Commit 55f17ba

Browse files
committed
TaskDetailData.kt: Remove deprecated properties from interface
* Remove implementations
1 parent 32bbdaf commit 55f17ba

File tree

3 files changed

+1
-79
lines changed

3 files changed

+1
-79
lines changed

features/tasks/src/main/kotlin/com/edricchan/studybuddy/features/tasks/detail/data/TaskDetailData.kt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.edricchan.studybuddy.features.tasks.detail.data
22

33
import com.edricchan.studybuddy.features.tasks.data.model.TodoItem
4-
import com.edricchan.studybuddy.features.tasks.data.model.TodoProject
54
import com.edricchan.studybuddy.features.tasks.detail.data.state.TaskDetailState
65
import com.edricchan.studybuddy.features.tasks.domain.model.TaskItem
76
import kotlinx.coroutines.flow.StateFlow
@@ -13,27 +12,6 @@ interface TaskDetailData {
1312
/** The currently selected [TodoItem]'s ID. */
1413
val currentTaskId: String
1514

16-
/** The currently selected [TodoItem]'s data. (Alias of `currTaskFlow.value`) */
17-
@Deprecated(
18-
"This may return the initial `null` value if the underlying flow" +
19-
"hasn't started emitting values. Use the currentTask() suspend method " +
20-
"instead to get the current value (note that it returns the domain-specific " +
21-
"TaskItem data class)."
22-
)
23-
val currentTask: TodoItem?
24-
get() = currTaskFlow.value
25-
26-
/** The currently selected [TodoItem]'s data, as a [StateFlow]. */
27-
@Deprecated(
28-
"There is an ambiguity between having no such task item " +
29-
"existing (represented by `null`) and the initial `null` value when the underlying " +
30-
"flow has yet to start emitting values. Use the currentTaskStateFlow property " +
31-
"instead which uses a sealed interface to differentiate between these 2 possible " +
32-
"states. Note that the state class uses the domain-specific TaskItem data class " +
33-
"which also provides access to the project-related information, if any."
34-
)
35-
val currTaskFlow: StateFlow<TodoItem?>
36-
3715
/** The currently selected task data, as a [StateFlow] of [TaskDetailState]. */
3816
val currentTaskStateFlow: StateFlow<TaskDetailState>
3917

@@ -46,13 +24,6 @@ interface TaskDetailData {
4624
return currentTaskStateFlow.filterIsInstance<TaskDetailState.Success>()
4725
.first().item
4826
}
49-
50-
/** The currently selected [TodoItem]'s [TodoProject] data, as a [StateFlow]. */
51-
@Deprecated(
52-
"The project data is now available in the TaskItem domain class. " +
53-
"To get the current task data, use the currentTaskStateFlow property"
54-
)
55-
val currTaskProjectFlow: StateFlow<TodoProject?>
5627
}
5728

5829
/**
Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
package com.edricchan.studybuddy.features.tasks.detail.data.impl
22

3-
import com.edricchan.studybuddy.features.tasks.data.model.TodoItem
4-
import com.edricchan.studybuddy.features.tasks.data.model.TodoProject
5-
import com.edricchan.studybuddy.features.tasks.data.repo.TaskProjectDataSource
63
import com.edricchan.studybuddy.features.tasks.data.repo.TaskRepository
74
import com.edricchan.studybuddy.features.tasks.detail.data.TaskDetailData
85
import com.edricchan.studybuddy.features.tasks.detail.data.state.TaskDetailState
96
import dagger.assisted.Assisted
107
import dagger.assisted.AssistedFactory
118
import dagger.assisted.AssistedInject
129
import kotlinx.coroutines.CoroutineScope
13-
import kotlinx.coroutines.ExperimentalCoroutinesApi
1410
import kotlinx.coroutines.flow.SharingStarted
1511
import kotlinx.coroutines.flow.StateFlow
1612
import kotlinx.coroutines.flow.catch
17-
import kotlinx.coroutines.flow.flatMapConcat
18-
import kotlinx.coroutines.flow.flowOf
1913
import kotlinx.coroutines.flow.map
2014
import kotlinx.coroutines.flow.stateIn
2115

2216
class FirestoreTaskDetailData @AssistedInject constructor(
2317
@Assisted private val selectedTaskId: String,
2418
@Assisted private val coroutineScope: CoroutineScope,
25-
repo: TaskRepository,
26-
private val projectSource: TaskProjectDataSource
19+
repo: TaskRepository
2720
) : TaskDetailData {
2821
@AssistedFactory
2922
fun interface Factory {
@@ -32,17 +25,6 @@ class FirestoreTaskDetailData @AssistedInject constructor(
3225

3326
override val currentTaskId: String = selectedTaskId
3427

35-
@Deprecated(
36-
"There is an ambiguity between having no such task item " +
37-
"existing (represented by `null`) and the initial `null` value when the underlying " +
38-
"flow has yet to start emitting values. Use the currentTaskStateFlow property " +
39-
"instead which uses a sealed interface to differentiate between these 2 possible " +
40-
"states. Note that the state class uses the domain-specific TaskItem data class " +
41-
"which also provides access to the project-related information, if any."
42-
)
43-
override val currTaskFlow: StateFlow<TodoItem?> = repo.observeTask(selectedTaskId)
44-
.stateIn(coroutineScope, SharingStarted.WhileSubscribed(), null)
45-
4628
override val currentTaskStateFlow: StateFlow<TaskDetailState> =
4729
repo.observeTaskById(selectedTaskId)
4830
.map {
@@ -55,16 +37,4 @@ class FirestoreTaskDetailData @AssistedInject constructor(
5537
started = SharingStarted.WhileSubscribed(),
5638
initialValue = TaskDetailState.Loading
5739
)
58-
59-
@Suppress("DEPRECATION")
60-
@Deprecated(
61-
"The project data is now available in the TaskItem domain class. " +
62-
"To get the current task data, use the currentTaskStateFlow property"
63-
)
64-
@OptIn(ExperimentalCoroutinesApi::class)
65-
override val currTaskProjectFlow: StateFlow<TodoProject?> = currTaskFlow
66-
.flatMapConcat { item ->
67-
item?.project?.id?.let(projectSource::get) ?: flowOf(null)
68-
}
69-
.stateIn(coroutineScope, SharingStarted.WhileSubscribed(), null)
7040
}

features/tasks/src/main/kotlin/com/edricchan/studybuddy/features/tasks/vm/TaskDetailViewModel.kt

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import androidx.lifecycle.viewModelScope
77
import androidx.navigation.toRoute
88
import com.edricchan.studybuddy.core.compat.navigation.CompatDestination
99
import com.edricchan.studybuddy.features.tasks.R
10-
import com.edricchan.studybuddy.features.tasks.data.model.TodoItem
11-
import com.edricchan.studybuddy.features.tasks.data.model.TodoProject
1210
import com.edricchan.studybuddy.features.tasks.data.repo.TaskRepository
1311
import com.edricchan.studybuddy.features.tasks.data.repo.setCompletion
1412
import com.edricchan.studybuddy.features.tasks.data.repo.toggleArchived
@@ -44,25 +42,8 @@ class TaskDetailViewModel @Inject constructor(
4442
private val detailData =
4543
detailDataFactory.create(selectedTaskId = routeData.taskId, coroutineScope = viewModelScope)
4644

47-
@Suppress("DEPRECATION") // Deprecation usage from FirestoreDetailData::currTaskFlow
48-
@Deprecated(
49-
"There is an ambiguity between having no such task item actually " +
50-
"existing (represented by `null`) and the initial `null` value when the underlying " +
51-
"flow has yet to start emitting values. Use the currentTaskStateFlow property " +
52-
"instead which uses a sealed interface to differentiate between these 2 possible " +
53-
"states. Note that the state class uses the domain-specific TaskItem data class " +
54-
"which also provides access to the project-related information, if any."
55-
)
56-
override val currTaskFlow: StateFlow<TodoItem?> by detailData::currTaskFlow
5745
override val currentTaskStateFlow: StateFlow<TaskDetailState> by detailData::currentTaskStateFlow
5846

59-
@Suppress("DEPRECATION") // Deprecation usage from FirestoreDetailData::currTaskProjectFlow
60-
@Deprecated(
61-
"The project data is now available in the TaskItem domain class. " +
62-
"To get the current task data, use the currentTaskStateFlow property"
63-
)
64-
override val currTaskProjectFlow: StateFlow<TodoProject?> by detailData::currTaskProjectFlow
65-
6647
suspend fun toggleCompleted(item: TaskItem) {
6748
repo.toggleCompleted(item)
6849
}

0 commit comments

Comments
 (0)