From 7cb05b77c64de908b0bea1c4b87f405efe562c23 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 16 Oct 2026 15:07:09 -0400 Subject: [PATCH] Android drawer: rememberTagViews lives with the recent-tags code (#5931) detekt's function-count limit on BoardScreen.kt. Co-Authored-By: Claude Opus 5.5 --- .../com/fabledsword/inkwell/ui/BoardScreen.kt | 17 -------------- .../com/fabledsword/inkwell/ui/RecentTags.kt | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/android/app/src/main/java/com/fabledsword/inkwell/ui/BoardScreen.kt b/android/app/src/main/java/com/fabledsword/inkwell/ui/BoardScreen.kt index 5136441..047f367 100644 --- a/android/app/src/main/java/com/fabledsword/inkwell/ui/BoardScreen.kt +++ b/android/app/src/main/java/com/fabledsword/inkwell/ui/BoardScreen.kt @@ -69,13 +69,11 @@ import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.boundsInRoot import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.platform.LocalConfiguration -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.unit.dp import androidx.compose.ui.zIndex import com.fabledsword.inkwell.R -import com.fabledsword.inkwell.TagViews import com.fabledsword.inkwell.core.Label import com.fabledsword.inkwell.core.Note import kotlinx.coroutines.launch @@ -402,21 +400,6 @@ private fun SearchBar( } } -/** - * When each tag's lens was last opened here. Opening one counts as using it, - * however it was opened: from the drawer, or a tag on a card (#5931). - */ -@Composable -private fun rememberTagViews(destination: Destination): Map { - val context = LocalContext.current - val tagViews = remember(context) { TagViews(context) } - var views by remember { mutableStateOf(tagViews.all()) } - LaunchedEffect(destination) { - if (destination is Destination.WithLabel) views = tagViews.record(destination.id) - } - return views -} - @Composable private fun NavigationDrawer( current: Destination, diff --git a/android/app/src/main/java/com/fabledsword/inkwell/ui/RecentTags.kt b/android/app/src/main/java/com/fabledsword/inkwell/ui/RecentTags.kt index 3caa935..5f59315 100644 --- a/android/app/src/main/java/com/fabledsword/inkwell/ui/RecentTags.kt +++ b/android/app/src/main/java/com/fabledsword/inkwell/ui/RecentTags.kt @@ -1,5 +1,13 @@ package com.fabledsword.inkwell.ui +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.platform.LocalContext +import com.fabledsword.inkwell.TagViews import com.fabledsword.inkwell.core.Label import com.fabledsword.inkwell.core.Note import java.time.OffsetDateTime @@ -50,3 +58,18 @@ fun tagRecency( /** 0 for a missing or unreadable stamp: such a tag simply ranks last. */ fun epochMillis(stamp: String?): Long = stamp?.let { runCatching { OffsetDateTime.parse(it).toInstant().toEpochMilli() }.getOrNull() } ?: 0L + +/** + * When each tag's lens was last opened here. Opening one counts as using it, + * however it was opened: from the drawer, or a tag on a card (#5931). + */ +@Composable +internal fun rememberTagViews(destination: Destination): Map { + val context = LocalContext.current + val tagViews = remember(context) { TagViews(context) } + var views by remember { mutableStateOf(tagViews.all()) } + LaunchedEffect(destination) { + if (destination is Destination.WithLabel) views = tagViews.record(destination.id) + } + return views +}