Skip to content

Commit ce9246a

Browse files
committed
allow deselect preselected tags
1 parent f209121 commit ce9246a

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

domain/src/main/java/com/example/util/simpletimetracker/domain/record/interactor/AddRunningRecordMediator.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class AddRunningRecordMediator @Inject constructor(
7575
timeStarted: StartTime = StartTime.TakeCurrent,
7676
updateNotificationSwitch: Boolean = true,
7777
checkDefaultDuration: Boolean = true,
78+
useSelectedTags: Boolean = false,
7879
) = coroutineScope {
7980
val currentTime = currentTimestampProvider.get()
8081
val actualTimeStarted = when (timeStarted) {
@@ -116,11 +117,15 @@ class AddRunningRecordMediator @Inject constructor(
116117
is StartTime.Timestamp -> currentTime
117118
},
118119
)
119-
val actualTags = getAllTags(
120-
typeId = typeId,
121-
currentTags = tags,
122-
tagValuesFromRules = rulesResult.tags,
123-
)
120+
val actualTags = if (useSelectedTags) {
121+
tags
122+
} else {
123+
getAllTags(
124+
typeId = typeId,
125+
currentTags = tags,
126+
tagValuesFromRules = rulesResult.tags,
127+
)
128+
}
124129
activityStartedStoppedBroadcastInteractor.onActionActivityStarted(
125130
typeId = typeId,
126131
tagIds = actualTags.map { it.tagId },

domain/src/test/java/com/example/util/simpletimetracker/domain/mapper/AddRunningRecordMediatorTest.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class AddRunningRecordMediatorTest {
155155
timeStarted = eq(AddRunningRecordMediator.StartTime.TakeCurrent),
156156
updateNotificationSwitch = eq(true),
157157
checkDefaultDuration = eq(true),
158+
useSelectedTags = eq(false),
158159
)
159160
}
160161

@@ -186,6 +187,7 @@ class AddRunningRecordMediatorTest {
186187
timeStarted = any(),
187188
updateNotificationSwitch = any(),
188189
checkDefaultDuration = any(),
190+
useSelectedTags = any(),
189191
)
190192
}
191193

@@ -213,6 +215,7 @@ class AddRunningRecordMediatorTest {
213215
timeStarted = eq(AddRunningRecordMediator.StartTime.TakeCurrent),
214216
updateNotificationSwitch = eq(false),
215217
checkDefaultDuration = eq(true),
218+
useSelectedTags = eq(false),
216219
)
217220
}
218221

@@ -266,6 +269,36 @@ class AddRunningRecordMediatorTest {
266269
verify(pomodoroStartInteractor).checkAndStart(typeId)
267270
}
268271

272+
@Test
273+
fun startTimerUseSelectedTags(): Unit = runBlocking {
274+
val selectedTags = listOf(tag(tagId2, 2.5))
275+
276+
subject.startTimer(
277+
typeId = typeId,
278+
tags = selectedTags,
279+
comment = "comment",
280+
timeStarted = AddRunningRecordMediator.StartTime.TakeCurrent,
281+
updateNotificationSwitch = true,
282+
checkDefaultDuration = true,
283+
useSelectedTags = true,
284+
)
285+
286+
verify(recordTypeToDefaultTagInteractor, never()).getTags(any())
287+
verify(activityStartedStoppedBroadcastInteractor).onActionActivityStarted(
288+
typeId = typeId,
289+
tagIds = selectedTags.map { it.tagId },
290+
comment = "comment",
291+
)
292+
verify(runningRecordInteractor).add(
293+
RunningRecord(
294+
id = typeId,
295+
timeStarted = currentTime,
296+
comment = "comment",
297+
tags = selectedTags,
298+
),
299+
)
300+
}
301+
269302
@Test
270303
fun multitaskingEnabled(): Unit = runBlocking {
271304
// Given

features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/interactor/ActivityStartStopFromBroadcastInteractor.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ class ActivityStartStopFromBroadcastInteractor @Inject constructor(
243243
typeId = selectedTypeId,
244244
comment = "",
245245
tags = selectedTags,
246+
useSelectedTags = true,
246247
)
247248
}
248249

features/feature_tag_selection/src/main/java/com/example/util/simpletimetracker/feature_tag_selection/viewModel/RecordTagSelectionViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ class RecordTagSelectionViewModel @Inject constructor(
148148
typeId = extra.typeId,
149149
tags = newTags,
150150
comment = newComment,
151+
useSelectedTags = true,
151152
)
152153
if (showAllTags) {
153154
addTagToTypeIfNotExistMediator.execute(
@@ -159,7 +160,6 @@ class RecordTagSelectionViewModel @Inject constructor(
159160
}
160161

161162
// TODO TAG add check retroactive mode to loaded preselected tags?
162-
// TODO TAG ability to deselect preselected tags
163163
private suspend fun initializeData() {
164164
if (initialDataLoaded) return
165165
newTags = loadPreselectedTagsInteractor.execute(extra.typeId)

features/feature_wear/src/main/java/com/example/util/simpletimetracker/feature_wear/WearDataRepo.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class WearDataRepo @Inject constructor(
170170
)
171171
},
172172
comment = "",
173+
useSelectedTags = true,
173174
)
174175
if (recordTypeInteractor.get(typeId)?.defaultDuration.orZero() > 0) {
175176
updateExternalViewsInteractor.get().onInstantRecordAdd()

0 commit comments

Comments
 (0)