- Note.manualLabelIds (NoteAccess.kt): the tags attached by hand, which the label picker, the chip's remove button and the board's create-label each filtered out of note.labels. - sharerName(note): who shared a note, or "Someone", which the shared-by line and the card's chip each spelled out. Checked with ktlint in the CI image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -505,8 +505,7 @@ class BoardViewModel(
|
|||||||
action.name.trim().takeIf { it.isNotEmpty() }?.let { name ->
|
action.name.trim().takeIf { it.isNotEmpty() }?.let { name ->
|
||||||
mutate {
|
mutate {
|
||||||
val label = it.createLabel(name)
|
val label = it.createLabel(name)
|
||||||
val manual = note.labels.filterNot { l -> l.viaTag }.map { l -> l.id }
|
it.setNoteLabels(id, (note.manualLabelIds + label.id).distinct())
|
||||||
it.setNoteLabels(id, (manual + label.id).distinct())
|
|
||||||
}
|
}
|
||||||
// The drawer lists labels with their note counts, and both
|
// The drawer lists labels with their note counts, and both
|
||||||
// just changed.
|
// just changed.
|
||||||
|
|||||||
@@ -361,10 +361,7 @@ fun EditorLabelRow(
|
|||||||
// Only the MANUAL labels are sent: the core replaces
|
// Only the MANUAL labels are sent: the core replaces
|
||||||
// exactly those, and including a tag label here would ask
|
// exactly those, and including a tag label here would ask
|
||||||
// it to own something the body text already owns.
|
// it to own something the body text already owns.
|
||||||
val kept =
|
val kept = note.manualLabelIds - label.id
|
||||||
note.labels
|
|
||||||
.filterNot { it.viaTag || it.id == label.id }
|
|
||||||
.map { it.id }
|
|
||||||
onAction(EditorAction.SetLabels(kept))
|
onAction(EditorAction.SetLabels(kept))
|
||||||
}) {
|
}) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|||||||
@@ -76,11 +76,7 @@ fun LabelSheet(
|
|||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
) {
|
) {
|
||||||
var typed by remember { mutableStateOf("") }
|
var typed by remember { mutableStateOf("") }
|
||||||
val manual =
|
val manual = note.manualLabelIds.toSet()
|
||||||
note.labels
|
|
||||||
.filterNot { it.viaTag }
|
|
||||||
.map { it.id }
|
|
||||||
.toSet()
|
|
||||||
val viaTag =
|
val viaTag =
|
||||||
note.labels
|
note.labels
|
||||||
.filter { it.viaTag }
|
.filter { it.viaTag }
|
||||||
|
|||||||
@@ -29,3 +29,11 @@ val Note.readOnlyHere: Boolean
|
|||||||
/** The owner's own controls apply: tags, reminder, files, previews, share, trash. */
|
/** The owner's own controls apply: tags, reminder, files, previews, share, trash. */
|
||||||
val Note.ownerControlsHere: Boolean
|
val Note.ownerControlsHere: Boolean
|
||||||
get() = !readOnlyHere && access == NoteAccess.OWNER
|
get() = !readOnlyHere && access == NoteAccess.OWNER
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tags attached by hand (the picker, or a lifted line), as opposed to the ones
|
||||||
|
* the body's own `#tags` carry. A label write sets exactly these; a body tag is the
|
||||||
|
* body's to keep.
|
||||||
|
*/
|
||||||
|
val Note.manualLabelIds: List<String>
|
||||||
|
get() = labels.filterNot { it.viaTag }.map { it.id }
|
||||||
|
|||||||
@@ -456,10 +456,7 @@ private fun SharedChip(note: Note) {
|
|||||||
val text =
|
val text =
|
||||||
when {
|
when {
|
||||||
note.access != NoteAccess.OWNER ->
|
note.access != NoteAccess.OWNER ->
|
||||||
stringResource(
|
stringResource(R.string.share_chip_by, sharerName(note))
|
||||||
R.string.share_chip_by,
|
|
||||||
note.sharedBy?.displayName?.takeIf { it.isNotBlank() } ?: stringResource(R.string.share_someone),
|
|
||||||
)
|
|
||||||
note.shared -> stringResource(R.string.share_chip_shared)
|
note.shared -> stringResource(R.string.share_chip_shared)
|
||||||
else -> return
|
else -> return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,16 @@ import com.fabledsword.inkwell.core.NoteShare
|
|||||||
import com.fabledsword.inkwell.core.ShareGroup
|
import com.fabledsword.inkwell.core.ShareGroup
|
||||||
import com.fabledsword.inkwell.core.ShareTarget
|
import com.fabledsword.inkwell.core.ShareTarget
|
||||||
|
|
||||||
|
/** Who shared [note] with us, by name, or "Someone" when the server sent none. */
|
||||||
|
@Composable
|
||||||
|
internal fun sharerName(note: Note): String =
|
||||||
|
note.sharedBy?.displayName?.takeIf { it.isNotBlank() } ?: stringResource(R.string.share_someone)
|
||||||
|
|
||||||
/** "Shared by Robin · view only" over someone else's note; nothing over our own. */
|
/** "Shared by Robin · view only" over someone else's note; nothing over our own. */
|
||||||
@Composable
|
@Composable
|
||||||
fun SharedByLine(note: Note) {
|
fun SharedByLine(note: Note) {
|
||||||
if (note.access == NoteAccess.OWNER) return
|
if (note.access == NoteAccess.OWNER) return
|
||||||
val who = note.sharedBy?.displayName?.takeIf { it.isNotBlank() } ?: stringResource(R.string.share_someone)
|
val who = sharerName(note)
|
||||||
val line =
|
val line =
|
||||||
if (note.access == NoteAccess.EDIT) {
|
if (note.access == NoteAccess.EDIT) {
|
||||||
stringResource(R.string.share_by_can_edit, who)
|
stringResource(R.string.share_by_can_edit, who)
|
||||||
|
|||||||
Reference in New Issue
Block a user