Panics · P29 Mail: gone boxes, labels and mails mark none; a moment no zone holds reads as none

This commit is contained in:
ZacharyZhang-NY committed 2026-10-07 03:28:36 -04:00
1 parent bb8732ac64
commit 0e64693688
6 files changed
+41 -13

No files matched your search

+3 -1
View File
@@ -152,7 +152,9 @@ impl RenderOnce for MailboxList {
.iter()
.flat_map(|(_, boxes)| boxes)
.any(|mailbox| mailbox.key == *open);
assert!(listed, "no mailbox {open}");
if !listed {
log::error!("mailbox list: no mailbox {open}; none open");
}
}
let open: OnValue = {
let (id, on_open) = (self.id.clone(), self.on_open.clone());
+6 -1
View File
@@ -120,7 +120,12 @@ impl RenderOnce for LabelPicker {
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
for key in &self.selected {
let known = self.labels.iter().any(|label| label.key == *key);
assert!(known, "label picker {:?}: no label {key}", self.id);
if !known {
log::error!(
"label picker {:?}: no label {key}; it is not ticked",
self.id
);
}
}
let finding = window.use_keyed_state(
(self.id.clone(), "finding"),
+3 -1
View File
@@ -284,7 +284,9 @@ impl RenderOnce for MailList {
fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
for key in &self.selected {
let listed = self.mails.iter().any(|mail| mail.key == *key);
assert!(listed, "no mail {key}");
if !listed {
log::error!("mail list: no mail {key}; it is not selected");
}
}
let theme = cx.theme();
if self.mails.is_empty() {
+13 -4
View File
@@ -128,12 +128,21 @@ fn a_label_name_is_listed_once() {
}
#[gpui::test]
#[should_panic(expected = "no label ghost")]
fn what_is_on_is_a_label(cx: &mut TestAppContext) {
fn a_label_mail_or_box_that_left_draws_unmarked(cx: &mut TestAppContext) {
let _ = mailing(
|_| {
LabelPicker::new("labels", [Label::new("a", "A", 0)])
.selected(["ghost"])
let mail = crate::mail::Mail::new("m1", "Ada", "Plans", Timestamp::UNIX_EPOCH);
let inbox =
crate::mail::Mailbox::new("inbox", "Inbox", crate::primitives::IconName::Inbox);
div()
.w(px(480.0))
.child(LabelPicker::new("labels", [Label::new("a", "A", 0)]).selected(["ghost"]))
.child(crate::mail::MailList::new("mails", [mail]).selected(["gone"]))
.child(
crate::mail::MailboxList::new("boxes")
.section("Mail", [inbox])
.open("gone"),
)
.into_any_element()
},
cx,
+14 -5
View File
@@ -40,12 +40,15 @@ pub(super) fn named(name: &str, at: Timestamp, zone: &TimeZone) -> (String, Time
(format!("{name} · {hour}"), at)
}
/// The moment `chosen` names in `zone`, once it lies after `now`.
/// The moment `chosen` names in `zone`, once it lies after `now`; none past the times jiff holds.
pub(super) fn ahead(chosen: DateTime, zone: &TimeZone, now: Timestamp) -> Option<Timestamp> {
let at = chosen
.to_zoned(zone.clone())
.expect("the zone holds the time")
.timestamp();
let at = match chosen.to_zoned(zone.clone()) {
Ok(at) => at.timestamp(),
Err(error) => {
log::error!("time dialog: {chosen} has no moment in its zone: {error}");
return None;
}
};
(at > now).then_some(at)
}
@@ -197,5 +200,11 @@ mod tests {
None,
"10:00 in Tokyo is 01:00 here"
);
let west = TimeZone::fixed(offset(-9));
assert_eq!(
ahead(jiff::civil::DateTime::MAX, &west, now),
None,
"past what jiff holds"
);
}
}