Skip to main content

max / goingson

Read a row's controls and badges by role, as quasi now holds them
Author: Max Johnson <me@maxj.phd> · 2026-08-12 16:58 UTC
Signed with PGP, not checked
Commit: 533280b855679b0005bdc41bf0c834ab1d2ef6b8
Parent: d726565
2 files changed, +27 insertions, -6 deletions
M Cargo.lock +1 -1
@@ -1418,7 +1418,7 @@
1418 1418
1419 1419 [[package]]
1420 1420 name = "docengine"
1421 - version = "0.5.0"
1421 + version = "0.7.0"
1422 1422 dependencies = [
1423 1423 "ammonia",
1424 1424 "pulldown-cmark",
@@ -122,6 +122,30 @@
122 122 }
123 123 }
124 124
125 + /// The controls a row offers, and the badges on it.
126 + ///
127 + /// A row's content is an inline run of parts since quasi `1786cb94`, so
128 + /// `row.actions` and `row.tokens` are gone and the parts carrying them are
129 + /// found by role. Two helpers rather than the filter written out at each
130 + /// assertion: what these tests want to say is "the controls this row offers",
131 + /// and `Row::primary` already sets the precedent of answering that question for
132 + /// the caller.
133 + fn acts(row: &Row) -> impl Iterator<Item = &quasi_router::screen::Act> {
134 + row.role(makeover_layout::RowPart::Actions)
135 + .filter_map(|node| match node {
136 + Node::Act(act) => Some(act),
137 + _ => None,
138 + })
139 + }
140 +
141 + fn tokens(row: &Row) -> impl Iterator<Item = &quasi_router::screen::Tag> {
142 + row.role(makeover_layout::RowPart::Tokens)
143 + .filter_map(|node| match node {
144 + Node::Token(tag) => Some(tag),
145 + _ => None,
146 + })
147 + }
148 +
125 149 /// What a list fragment says is left, and how to ask for it.
126 150 fn remainder(response: Response) -> Option<quasi_router::screen::Rest> {
127 151 match response.outcome {
@@ -244,7 +268,7 @@
244 268 // A control that dropped the filter is a view you fall out of by using it.
245 269 let opening = listed[0].activate.as_ref().expect("a row opens its thread");
246 270 assert_eq!(opening.carried.get("folder"), Some("Archive"));
247 - for act in &listed[0].actions {
271 + for act in acts(&listed[0]) {
248 272 assert_eq!(
249 273 act.action.carried.get("folder"),
250 274 Some("Archive"),
@@ -528,10 +552,7 @@
528 552 let listed = rows(get(&state, "/emails/list", Params::new()));
529 553 assert_eq!(listed.len(), 1, "a thread is one row");
530 554 assert!(
531 - listed[0]
532 - .tokens
533 - .iter()
534 - .any(|tag| tag.label.contains("2 messages")),
555 + tokens(&listed[0]).any(|tag| tag.label.contains("2 messages")),
535 556 "the count says what it counts rather than showing a bare digit",
536 557 );
537 558 }