A day's list leaves out hidden lists like its dots, and a task added there is due that day (#59)
This commit is contained in:
1 parent
ed44961367
commit
70a70c327c
5 files changed
+27
-6
No files matched your search
@@ -196,8 +196,9 @@ data class Settings(
|
||||
now: Instant = Clock.System.now(),
|
||||
zone: ZoneId = ZoneId.systemDefault(),
|
||||
): SmartView {
|
||||
if (filter !is TaskFilter.Smart) return SmartView(tasks, hiddenByRange = false)
|
||||
val end = if (filter.list == SmartList.UPCOMING) upcomingRange.end(now, zone) else null
|
||||
// A day of the week strip leaves out the same lists as the smart lists, as its dots do.
|
||||
if (filter !is TaskFilter.Smart && filter !is TaskFilter.DueOn) return SmartView(tasks, hiddenByRange = false)
|
||||
val end = if ((filter as? TaskFilter.Smart)?.list == SmartList.UPCOMING) upcomingRange.end(now, zone) else null
|
||||
if (hiddenFromSmartLists.isEmpty() && end == null) return SmartView(tasks, hiddenByRange = false)
|
||||
var hiddenByRange = false
|
||||
val kept = tasks.filter { task ->
|
||||
|
||||
@@ -228,6 +228,7 @@ class TaskEditViewModel @Inject constructor(
|
||||
presetTag: String? = null,
|
||||
presetFilterId: Long? = null,
|
||||
presetSmartList: SmartList? = null,
|
||||
presetDueDate: LocalDate? = null,
|
||||
) {
|
||||
if (bound) return
|
||||
bound = true
|
||||
@@ -247,9 +248,14 @@ class TaskEditViewModel @Inject constructor(
|
||||
val (todayStart, todayEnd) = DayWindow.today(now, zone)
|
||||
val upcomingEnd = settings.upcomingRange.end(now, zone)
|
||||
val ruleClock = RuleClock(todayStart, todayEnd, zone, settingsPrefs.firstDayOfWeek.first())
|
||||
val presetDue = preset?.dueDate ?: presetSmartList?.dueWindows?.presetDue(today)
|
||||
val dates = settings.defaultNewTaskDates(today, now, presetDue, subtask = parentId != null) {
|
||||
it.showsIn(presetSmartList, filter, todayStart, todayEnd, upcomingEnd, ruleClock)
|
||||
val presetDue = presetDueDate ?: preset?.dueDate ?: presetSmartList?.dueWindows?.presetDue(today)
|
||||
val dates = settings.defaultNewTaskDates(today, now, presetDue, subtask = parentId != null) { dates ->
|
||||
// A day's list wants the task on that day, whatever the default due date.
|
||||
if (presetDueDate != null) {
|
||||
dates.due?.calendarDate(dates.isAllDay, zone) == presetDueDate
|
||||
} else {
|
||||
dates.showsIn(presetSmartList, filter, todayStart, todayEnd, upcomingEnd, ruleClock)
|
||||
}
|
||||
}
|
||||
// A read-only or vanished default — or a widget's preset list, if it was
|
||||
// since deleted or turned read-only — would give the task a list it
|
||||
|
||||
@@ -217,6 +217,7 @@ fun AgendulaNavHost(
|
||||
tag = (filter as? TaskFilter.Tagged)?.tag,
|
||||
filterId = (filter as? TaskFilter.Saved)?.id,
|
||||
smartList = (filter as? TaskFilter.Smart)?.list,
|
||||
due = (filter as? TaskFilter.DueOn)?.date,
|
||||
),
|
||||
)
|
||||
},
|
||||
@@ -295,6 +296,7 @@ fun AgendulaNavHost(
|
||||
val tag = args?.getString(Dest.TaskEdit.ARG_TAG)
|
||||
val filterId = args?.getLong(Dest.TaskEdit.ARG_FILTER_ID)?.takeIf { it != Dest.NO_ID }
|
||||
val smartList = smartListNamed(args?.getString(Dest.TaskEdit.ARG_SMART_LIST))
|
||||
val presetDue = args?.getString(Dest.TaskEdit.ARG_DUE)?.let { runCatching { java.time.LocalDate.parse(it) }.getOrNull() }
|
||||
val vm: TaskEditViewModel = hiltViewModel()
|
||||
LaunchedEffect(taskId, presetListId, parentId) {
|
||||
if (taskId != Dest.NO_ID) {
|
||||
@@ -307,6 +309,7 @@ fun AgendulaNavHost(
|
||||
presetTag = tag,
|
||||
presetFilterId = filterId,
|
||||
presetSmartList = smartList,
|
||||
presetDueDate = presetDue,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ object Dest {
|
||||
const val ARG_TAG = "tag"
|
||||
const val ARG_FILTER_ID = "filterId"
|
||||
const val ARG_SMART_LIST = "smartList"
|
||||
const val ARG_DUE = "due"
|
||||
const val route =
|
||||
"taskEdit?$ARG_TASK_ID={$ARG_TASK_ID}" +
|
||||
"&$ARG_PRESET_LIST_ID={$ARG_PRESET_LIST_ID}" +
|
||||
@@ -160,7 +161,8 @@ object Dest {
|
||||
"&$ARG_TITLE={$ARG_TITLE}" +
|
||||
"&$ARG_TAG={$ARG_TAG}" +
|
||||
"&$ARG_FILTER_ID={$ARG_FILTER_ID}" +
|
||||
"&$ARG_SMART_LIST={$ARG_SMART_LIST}"
|
||||
"&$ARG_SMART_LIST={$ARG_SMART_LIST}" +
|
||||
"&$ARG_DUE={$ARG_DUE}"
|
||||
|
||||
val arguments = listOf(
|
||||
navArgument(ARG_TASK_ID) { type = NavType.LongType; defaultValue = NO_ID },
|
||||
@@ -171,6 +173,7 @@ object Dest {
|
||||
navArgument(ARG_TAG) { type = NavType.StringType; nullable = true; defaultValue = null },
|
||||
navArgument(ARG_FILTER_ID) { type = NavType.LongType; defaultValue = NO_ID },
|
||||
navArgument(ARG_SMART_LIST) { type = NavType.StringType; nullable = true; defaultValue = null },
|
||||
navArgument(ARG_DUE) { type = NavType.StringType; nullable = true; defaultValue = null },
|
||||
)
|
||||
|
||||
fun buildEdit(taskId: Long, occurrenceStart: Long? = null): String =
|
||||
@@ -184,6 +187,7 @@ object Dest {
|
||||
tag: String? = null,
|
||||
filterId: Long? = null,
|
||||
smartList: SmartList? = null,
|
||||
due: java.time.LocalDate? = null,
|
||||
): String {
|
||||
val params = buildList {
|
||||
if (presetListId != null) add("$ARG_PRESET_LIST_ID=$presetListId")
|
||||
@@ -192,6 +196,7 @@ object Dest {
|
||||
if (!tag.isNullOrBlank()) add("$ARG_TAG=${android.net.Uri.encode(tag)}")
|
||||
if (filterId != null) add("$ARG_FILTER_ID=$filterId")
|
||||
if (smartList != null) add("$ARG_SMART_LIST=${smartList.name}")
|
||||
if (due != null) add("$ARG_DUE=$due")
|
||||
}
|
||||
return if (params.isEmpty()) "taskEdit" else "taskEdit?${params.joinToString("&")}"
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@ class SettingsVisibilityTest {
|
||||
assertThat(settings.visibleIn(TaskFilter.Smart(SmartList.ALL), tasks).map { it.taskId }).containsExactly(1L)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a day of the week strip leaves out a hidden list, as its dots do`() {
|
||||
val day = TaskFilter.DueOn(java.time.LocalDate.of(2026, 11, 26))
|
||||
assertThat(settings.visibleIn(day, tasks).map { it.taskId }).containsExactly(1L)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the hidden list still shows its own tasks`() {
|
||||
assertThat(settings.visibleIn(TaskFilter.OfList(2), tasks)).isEqualTo(tasks)
|
||||
|
||||
Reference in new issue
Block a user