Skip to content

Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.

Reminders carry priority and can move between lists

Yashwanth Kamireddif48b75beff75
diff --git a/.uiverify/shots.mjs b/.uiverify/shots.mjs
index 4740ea2..77a97fe 100644
--- a/.uiverify/shots.mjs
+++ b/.uiverify/shots.mjs
@@ -38,7 +38,7 @@ function installStub({ screen, services, twoFactor, calendarFixture, notesFixtur
];
const dueReminders = !calendarFixture ? [] : [
{ guid: "r1", listGuid: "daily", title: "Water the plants", notes: null,
- dueAt: base + DAY + 8 * HOUR, completedAt: null, priority: 0, etag: null },
+ dueAt: base + DAY + 8 * HOUR, completedAt: null, priority: 1, etag: null },
{ guid: "r2", listGuid: "health", title: "Evening run", notes: null,
dueAt: base + 6 * HOUR, completedAt: null, priority: 0, etag: null },
{ guid: "r3", listGuid: "daily", title: "Plan tomorrow", notes: null,
diff --git a/crates/quince-icloud/src/cloudkit.rs b/crates/quince-icloud/src/cloudkit.rs
index 911626a..22c634f 100644
--- a/crates/quince-icloud/src/cloudkit.rs
+++ b/crates/quince-icloud/src/cloudkit.rs
@@ -332,8 +332,25 @@ impl ZoneClient<'_> {
"recordType": record_type,
"fields": changes,
});
- if let Some(tag) = change_tag {
- record["recordChangeTag"] = Value::String(tag.to_string());
+
+ // CloudKit rejects an update with no change tag outright — not as a conflict, as a
+ // malformed request. The local copy legitimately may not have one yet: a record
+ // created a moment ago has a name before it has a tag. Fetching the current tag is
+ // what makes a write on a just-created record work instead of failing at 400.
+ let tag = match change_tag {
+ Some(tag) => Some(tag.to_string()),
+ None => self
+ .lookup_record(zone, record_name)
+ .await?
+ .and_then(|fresh| {
+ fresh
+ .get("recordChangeTag")
+ .and_then(Value::as_str)
+ .map(ToString::to_string)
+ }),
+ };
+ if let Some(tag) = tag {
+ record["recordChangeTag"] = Value::String(tag);
}
match self
@@ -651,6 +668,77 @@ mod conflict_tests {
);
}
+ /// CloudKit rejects an update with no change tag as a malformed request, not as a
+ /// conflict — so there is nothing to recover from afterwards. The local copy genuinely
+ /// may not have one: a record created a moment ago has a name before it has a tag, and
+ /// setting a priority on a reminder you just added hits exactly that.
+ #[tokio::test]
+ async fn a_write_without_a_local_tag_fetches_one_first() {
+ let server = MockServer::start().await;
+ Mock::given(method("POST"))
+ .and(path_regex(r".*/records/lookup$"))
+ .respond_with(ResponseTemplate::new(200).set_body_json(json!({
+ "records": [{ "recordName": "Reminder/1", "recordChangeTag": "current" }]
+ })))
+ .mount(&server)
+ .await;
+ Mock::given(method("POST"))
+ .and(path_regex(r".*/records/modify$"))
+ .respond_with(ResponseTemplate::new(200).set_body_json(json!({
+ "records": [{ "recordName": "Reminder/1" }]
+ })))
+ .mount(&server)
+ .await;
+
+ let http = reqwest::Client::new();
+ let client = ZoneClient::new(&http, &server.uri(), "com.apple.reminders", vec![]);
+ client
+ .update_record("Reminders", "Reminder/1", "Reminder", None, json!({}))
+ .await
+ .expect("a missing tag should be fetched, not fatal");
+
+ let requests = server.received_requests().await.unwrap();
+ let modify = requests
+ .iter()
+ .find(|r| r.url.path().ends_with("/modify"))
+ .expect("a modify was sent");
+ let body: Value = serde_json::from_slice(&modify.body).unwrap();
+ assert_eq!(
+ body["operations"][0]["record"]["recordChangeTag"], "current",
+ "the write must carry the tag Apple currently holds"
+ );
+ }
+
+ /// A tag we already hold is used as-is: fetching one on every write would double the
+ /// number of requests every edit costs.
+ #[tokio::test]
+ async fn a_known_tag_is_used_without_a_lookup() {
+ let server = MockServer::start().await;
+ Mock::given(method("POST"))
+ .and(path_regex(r".*/records/modify$"))
+ .respond_with(ResponseTemplate::new(200).set_body_json(json!({
+ "records": [{ "recordName": "Reminder/1" }]
+ })))
+ .mount(&server)
+ .await;
+
+ let http = reqwest::Client::new();
+ let client = ZoneClient::new(&http, &server.uri(), "com.apple.reminders", vec![]);
+ client
+ .update_record(
+ "Reminders",
+ "Reminder/1",
+ "Reminder",
+ Some("known"),
+ json!({}),
+ )
+ .await
+ .unwrap();
+
+ let requests = server.received_requests().await.unwrap();
+ assert_eq!(requests.len(), 1, "one request, not a lookup and a write");
+ }
+
/// If the record is gone, say so plainly rather than retrying forever.
#[tokio::test]
async fn a_vanished_record_is_reported_not_retried() {
diff --git a/crates/quince-icloud/src/reminders.rs b/crates/quince-icloud/src/reminders.rs
index d0899ae..f13e268 100644
--- a/crates/quince-icloud/src/reminders.rs
+++ b/crates/quince-icloud/src/reminders.rs
@@ -865,6 +865,10 @@ pub struct ReminderEdit {
pub due_at: Option<Option<i64>>,
pub flagged: Option<bool>,
pub completed: Option<bool>,
+ /// Apple's scale, shared with EventKit: 0 none, 1 high, 5 medium, 9 low.
+ pub priority: Option<i64>,
+ /// Move to another list.
+ pub list_guid: Option<String>,
}
impl ReminderEdit {
@@ -874,6 +878,8 @@ impl ReminderEdit {
&& self.due_at.is_none()
&& self.flagged.is_none()
&& self.completed.is_none()
+ && self.priority.is_none()
+ && self.list_guid.is_none()
}
}
@@ -933,6 +939,26 @@ pub async fn edit_cloudkit(
);
}
+ if let Some(priority) = edit.priority {
+ // Anything off Apple's scale would render as an unknown marker on a phone rather
+ // than being ignored, so it is clamped rather than passed through.
+ let level = match priority {
+ 1..=3 => 1,
+ 4..=6 => 5,
+ 7..=9 => 9,
+ _ => 0,
+ };
+ fields.insert(
+ "Priority".into(),
+ serde_json::json!({ "type": "NUMBER_INT64", "value": level }),
+ );
+ }
+
+ if let Some(list_guid) = &edit.list_guid {
+ let client = ZoneClient::new(http, ckdatabasews_root, CONTAINER, params.clone());
+ fields.insert("List".into(), client.reference_to(ZONE, list_guid));
+ }
+
if let Some(flagged) = edit.flagged {
fields.insert(
"Flagged".into(),
@@ -1684,9 +1710,15 @@ mod list_write_tests {
server
}
+ /// The write, not whatever lookup preceded it: an update with no local change tag
+ /// fetches the current one first, which is a request of its own.
async fn sent(server: &MockServer) -> Value {
let requests = server.received_requests().await.unwrap();
- serde_json::from_slice::<Value>(&requests[0].body).unwrap()["operations"][0].clone()
+ let modify = requests
+ .iter()
+ .find(|r| r.url.path().ends_with("/records/modify"))
+ .expect("a modify was sent");
+ serde_json::from_slice::<Value>(&modify.body).unwrap()["operations"][0].clone()
}
/// A list's name is a plain string, unlike a reminder's title — writing it as a document
@@ -2046,3 +2078,146 @@ mod recurring_tick_tests {
assert!(r.next_occurrence().is_none());
}
}
+
+#[cfg(test)]
+mod priority_and_move_tests {
+ use super::*;
+ use serde_json::json;
+ use wiremock::matchers::{method, path_regex};
+ use wiremock::{Mock, MockServer, ResponseTemplate};
+
+ async fn accepting() -> MockServer {
+ let server = MockServer::start().await;
+ Mock::given(method("POST"))
+ .and(path_regex(r".*/records/modify$"))
+ .respond_with(
+ ResponseTemplate::new(200)
+ .set_body_json(json!({ "records": [{ "recordName": "Reminder/1" }] })),
+ )
+ .mount(&server)
+ .await;
+ server
+ }
+
+ fn plain() -> Reminder {
+ Reminder {
+ guid: "Reminder/1".into(),
+ list_guid: "List/a".into(),
+ title: "Renew passport".into(),
+ notes: None,
+ due_at: None,
+ completed_at: None,
+ priority: 0,
+ flagged: false,
+ recur_frequency: None,
+ recur_interval: None,
+ etag: Some("tag".into()),
+ raw: None,
+ }
+ }
+
+ async fn fields(server: &MockServer) -> Value {
+ let requests = server.received_requests().await.unwrap();
+ serde_json::from_slice::<Value>(&requests[0].body).unwrap()["operations"][0]["record"]
+ ["fields"]
+ .clone()
+ }
+
+ async fn write(edit: ReminderEdit) -> Value {
+ let server = accepting().await;
+ edit_cloudkit(
+ &reqwest::Client::new(),
+ &server.uri(),
+ vec![],
+ &plain(),
+ &edit,
+ )
+ .await
+ .unwrap();
+ fields(&server).await
+ }
+
+ /// Apple's scale is 1 high, 5 medium, 9 low — the same one EventKit uses. Sending a
+ /// number off it would show as an unknown marker on a phone.
+ #[tokio::test]
+ async fn priority_lands_on_apples_own_scale() {
+ for (asked, stored) in [(1, 1), (2, 1), (5, 5), (6, 5), (9, 9), (7, 9), (0, 0)] {
+ let sent = write(ReminderEdit {
+ priority: Some(asked),
+ ..ReminderEdit::default()
+ })
+ .await;
+ assert_eq!(
+ sent["Priority"]["value"], stored,
+ "asking for {asked} should store {stored}"
+ );
+ }
+ }
+
+ #[tokio::test]
+ async fn an_out_of_range_priority_becomes_none_rather_than_nonsense() {
+ let sent = write(ReminderEdit {
+ priority: Some(42),
+ ..ReminderEdit::default()
+ })
+ .await;
+ assert_eq!(sent["Priority"]["value"], 0);
+ }
+
+ #[tokio::test]
+ async fn moving_rewrites_the_list_reference() {
+ let sent = write(ReminderEdit {
+ list_guid: Some("List/b".into()),
+ ..ReminderEdit::default()
+ })
+ .await;
+ assert_eq!(sent["List"]["type"], "REFERENCE");
+ assert_eq!(sent["List"]["value"]["recordName"], "List/b");
+ }
+
+ /// One request, so a move and a priority change cannot half-apply.
+ #[tokio::test]
+ async fn several_changes_go_in_one_write() {
+ let server = accepting().await;
+ edit_cloudkit(
+ &reqwest::Client::new(),
+ &server.uri(),
+ vec![],
+ &plain(),
+ &ReminderEdit {
+ title: Some("Renew passport urgently".into()),
+ priority: Some(1),
+ list_guid: Some("List/b".into()),
+ ..ReminderEdit::default()
+ },
+ )
+ .await
+ .unwrap();
+
+ assert_eq!(
+ server.received_requests().await.unwrap().len(),
+ 1,
+ "a single request"
+ );
+ let sent = fields(&server).await;
+ assert_eq!(sent["Priority"]["value"], 1);
+ assert_eq!(sent["List"]["value"]["recordName"], "List/b");
+ assert!(sent.get("TitleDocument").is_some());
+ }
+
+ /// An edit that asks for nothing must not reach Apple at all.
+ #[tokio::test]
+ async fn an_empty_edit_sends_nothing() {
+ let server = accepting().await;
+ edit_cloudkit(
+ &reqwest::Client::new(),
+ &server.uri(),
+ vec![],
+ &plain(),
+ &ReminderEdit::default(),
+ )
+ .await
+ .unwrap();
+ assert!(server.received_requests().await.unwrap().is_empty());
+ }
+}
diff --git a/probe/src/main.rs b/probe/src/main.rs
index 3da1d0a..0547fd5 100644
--- a/probe/src/main.rs
+++ b/probe/src/main.rs
@@ -1305,6 +1305,124 @@ async fn main() -> Result<()> {
}
}
+ // ---- do priority and moving actually work? -----------------------------------
+ // Create a reminder, set its priority, move it to another list, read each back from
+ // Apple, then delete it. Only ever touches the reminder it made. Runs with --write-test.
+ if std::env::args().any(|a| a == "--write-test") {
+ println!("\n\x1b[1m── Reminders: priority and moving ──\x1b[0m");
+ if let Some(ck) = session.service_url("ckdatabasews") {
+ let params = client.service_params();
+ let http = client.http().clone();
+ let lists = quince_core::Library::open(&dir)
+ .ok()
+ .and_then(|l| l.reminder_lists().ok())
+ .unwrap_or_default();
+
+ if lists.len() < 2 {
+ println!(
+ " need two lists to test a move; this account has {}",
+ lists.len()
+ );
+ } else {
+ let (from, to) = (&lists[0], &lists[1]);
+ match quince_icloud::reminders::create_cloudkit(
+ &http,
+ &ck,
+ params.clone(),
+ &from.guid,
+ "Quince write test — safe to delete",
+ )
+ .await
+ {
+ Err(e) => println!(" \x1b[31mFAIL\x1b[0m create: {e}"),
+ Ok(guid) => {
+ println!(" \x1b[32mPASS\x1b[0m created in {}", from.title);
+ let zc = quince_icloud::cloudkit::ZoneClient::new(
+ client.http(),
+ &ck,
+ "com.apple.reminders",
+ client.service_params(),
+ );
+ let reminder = quince_core::reminders::Reminder {
+ guid: guid.clone(),
+ list_guid: from.guid.clone(),
+ title: "Quince write test — safe to delete".into(),
+ notes: None,
+ due_at: None,
+ completed_at: None,
+ priority: 0,
+ flagged: false,
+ recur_frequency: None,
+ recur_interval: None,
+ etag: None,
+ raw: None,
+ };
+
+ let edit = quince_icloud::reminders::ReminderEdit {
+ priority: Some(1),
+ list_guid: Some(to.guid.clone()),
+ ..Default::default()
+ };
+ match quince_icloud::reminders::edit_cloudkit(
+ &http,
+ &ck,
+ params.clone(),
+ &reminder,
+ &edit,
+ )
+ .await
+ {
+ Err(e) => println!(" \x1b[31mFAIL\x1b[0m edit: {e}"),
+ Ok(()) => match zc.lookup_record("Reminders", &guid).await {
+ Ok(Some(rec)) => {
+ let priority =
+ quince_icloud::cloudkit::field::int(&rec, "Priority");
+ let list =
+ quince_icloud::cloudkit::field::reference(&rec, "List");
+ let moved = list.as_deref() == Some(to.guid.as_str());
+ println!(
+ " {} priority is {:?} (asked for high = 1)",
+ if priority == Some(1) {
+ "\x1b[32mPASS\x1b[0m"
+ } else {
+ "\x1b[31mFAIL\x1b[0m"
+ },
+ priority
+ );
+ println!(
+ " {} list is now {}",
+ if moved {
+ "\x1b[32mPASS\x1b[0m"
+ } else {
+ "\x1b[31mFAIL\x1b[0m"
+ },
+ if moved {
+ to.title.clone()
+ } else {
+ format!("{list:?}")
+ }
+ );
+ }
+ _ => println!(" \x1b[31mFAIL\x1b[0m the reminder vanished"),
+ },
+ }
+
+ match quince_icloud::reminders::delete_cloudkit(
+ &http, &ck, params, &reminder,
+ )
+ .await
+ {
+ Ok(()) => println!(" \x1b[32mPASS\x1b[0m deleted; nothing left behind"),
+ Err(e) => println!(
+ " \x1b[31mFAIL\x1b[0m delete: {e}\n \x1b[33mtest reminder {guid} is still there\x1b[0m"
+ ),
+ }
+ }
+ }
+ }
+ }
+ }
+
// ---- CloudKit containers ----------------------------------------------------
// Apple's legacy /rd and /ca endpoints answer with a placeholder once data has been
// upgraded to the modern format. The real records live in CloudKit, so find out which
diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts
index be90400..c318c05 100644
--- a/src/lib/ipc.ts
+++ b/src/lib/ipc.ts
@@ -156,6 +156,10 @@ export type ReminderEdit = {
dueAt?: number | null;
flagged?: boolean;
completed?: boolean;
+ /** Apple's scale: 0 none, 1 high, 5 medium, 9 low. */
+ priority?: number;
+ /** Move the reminder to another list. */
+ listGuid?: string;
};
export type Reminder = {
diff --git a/src/screens/RemindersView.tsx b/src/screens/RemindersView.tsx
index c32165a..f5f4945 100644
--- a/src/screens/RemindersView.tsx
+++ b/src/screens/RemindersView.tsx
@@ -19,7 +19,9 @@ const SMART: { kind: SmartList; title: string }[] = [
/** End of today in the viewer's own timezone — the interface knows it, the backend doesn't. */
function endOfToday(): number {
const d = new Date();
- return Math.floor(new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1).getTime() / 1000);
+ return Math.floor(
+ new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1).getTime() / 1000,
+ );
}
function dueLabel(seconds: number): { text: string; overdue: boolean } {
@@ -27,9 +29,20 @@ function dueLabel(seconds: number): { text: string; overdue: boolean } {
const now = new Date();
const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const days = Math.floor((due.getTime() - midnight.getTime()) / 86_400_000);
- const time = due.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" });
- if (days < 0) return { text: due.toLocaleDateString(undefined, { day: "numeric", month: "short" }), overdue: true };
- if (days === 0) return { text: `Today ${time}`, overdue: due.getTime() < now.getTime() };
+ const time = due.toLocaleTimeString(undefined, {
+ hour: "numeric",
+ minute: "2-digit",
+ });
+ if (days < 0)
+ return {
+ text: due.toLocaleDateString(undefined, {
+ day: "numeric",
+ month: "short",
+ }),
+ overdue: true,
+ };
+ if (days === 0)
+ return { text: `Today ${time}`, overdue: due.getTime() < now.getTime() };
if (days === 1) return { text: `Tomorrow ${time}`, overdue: false };
return {
text: due.toLocaleDateString(undefined, { day: "numeric", month: "short" }),
@@ -37,6 +50,17 @@ function dueLabel(seconds: number): { text: string; overdue: boolean } {
};
}
+/** Apple's scale, and the marks its own app puts before a title. */
+const PRIORITIES = [
+ { value: 0, label: "None", mark: "" },
+ { value: 1, label: "High", mark: "!!!" },
+ { value: 5, label: "Medium", mark: "!!" },
+ { value: 9, label: "Low", mark: "!" },
+] as const;
+
+const priorityMark = (priority: number) =>
+ PRIORITIES.find((p) => p.value === priority)?.mark ?? "";
+
const REPEAT_UNITS = ["day", "week", "month", "year"] as const;
/** "Every day", "Every 2 weeks" — or null when this happens only once. */
@@ -56,11 +80,15 @@ function toInputValue(seconds: number | null): string {
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
}
-type Selection = { type: "smart"; kind: SmartList } | { type: "list"; guid: string };
+type Selection =
+ { type: "smart"; kind: SmartList } | { type: "list"; guid: string };
export function RemindersView() {
const [lists, setLists] = useState<ReminderList[]>([]);
- const [selection, setSelection] = useState<Selection>({ type: "smart", kind: "today" });
+ const [selection, setSelection] = useState<Selection>({
+ type: "smart",
+ kind: "today",
+ });
const [items, setItems] = useState<Reminder[]>([]);
const [showDone, setShowDone] = useState(false);
const [syncing, setSyncing] = useState(false);
@@ -74,7 +102,9 @@ export function RemindersView() {
const [error, setError] = useState<string | null>(null);
const { revision } = useSync();
/** A repeating reminder that was just ticked forward, and where it landed. */
- const [moved, setMoved] = useState<{ guid: string; text: string } | null>(null);
+ const [moved, setMoved] = useState<{ guid: string; text: string } | null>(
+ null,
+ );
const inList = selection.type === "list";
const listGuid = inList ? selection.guid : null;
@@ -123,7 +153,10 @@ export function RemindersView() {
/** Every write goes through here: to Apple first, then re-read, so nothing on screen is a guess. */
const write = useCallback(
- async (reminder: Reminder, run: () => Promise<void>): Promise<Reminder[] | null> => {
+ async (
+ reminder: Reminder,
+ run: () => Promise<void>,
+ ): Promise<Reminder[] | null> => {
setBusyGuid(reminder.guid);
setError(null);
try {
@@ -136,7 +169,7 @@ export function RemindersView() {
setBusyGuid(null);
}
},
- [readItems]
+ [readItems],
);
/**
@@ -146,7 +179,9 @@ export function RemindersView() {
*/
const toggle = async (r: Reminder) => {
const wasOpen = !r.completedAt;
- const fresh = await write(r, () => api.reminderSetDone(r.guid, r.listGuid, wasOpen));
+ const fresh = await write(r, () =>
+ api.reminderSetDone(r.guid, r.listGuid, wasOpen),
+ );
if (!fresh || !wasOpen || repeatLabel(r) === null) return;
const after = fresh.find((x) => x.guid === r.guid);
if (after && after.dueAt !== null && after.dueAt !== r.dueAt) {
@@ -154,20 +189,33 @@ export function RemindersView() {
}
};
const flag = (r: Reminder) =>
- write(r, () => api.reminderEdit(r.guid, r.listGuid, { flagged: !r.flagged }));
- const remove = (r: Reminder) => write(r, () => api.reminderDelete(r.guid, r.listGuid));
+ write(r, () =>
+ api.reminderEdit(r.guid, r.listGuid, { flagged: !r.flagged }),
+ );
+ const remove = (r: Reminder) =>
+ write(r, () => api.reminderDelete(r.guid, r.listGuid));
const rename = (r: Reminder, title: string) =>
title.trim() && title.trim() !== r.title
- ? write(r, () => api.reminderEdit(r.guid, r.listGuid, { title: title.trim() }))
+ ? write(r, () =>
+ api.reminderEdit(r.guid, r.listGuid, { title: title.trim() }),
+ )
: Promise.resolve();
const setDue = (r: Reminder, value: string) =>
write(r, () =>
api.reminderEdit(r.guid, r.listGuid, {
dueAt: value ? Math.floor(new Date(value).getTime() / 1000) : null,
- })
+ }),
);
const setNotes = (r: Reminder, notes: string) =>
- write(r, () => api.reminderEdit(r.guid, r.listGuid, { notes: notes.trim() || null }));
+ write(r, () =>
+ api.reminderEdit(r.guid, r.listGuid, { notes: notes.trim() || null }),
+ );
+ const setPriority = (r: Reminder, priority: number) =>
+ write(r, () => api.reminderEdit(r.guid, r.listGuid, { priority }));
+ const moveToList = (r: Reminder, listGuid: string) =>
+ listGuid === r.listGuid
+ ? Promise.resolve(null)
+ : write(r, () => api.reminderEdit(r.guid, r.listGuid, { listGuid }));
/** List writes go to Apple first, then the whole set is re-read. */
const listWrite = useCallback(
@@ -184,7 +232,7 @@ export function RemindersView() {
setSyncing(false);
}
},
- [readLists, readItems]
+ [readLists, readItems],
);
async function createList(e: React.FormEvent) {
@@ -215,12 +263,13 @@ export function RemindersView() {
}
const heading = inList
- ? lists.find((l) => l.guid === listGuid)?.title ?? "Reminders"
- : SMART.find((s) => s.kind === (selection as { kind: SmartList }).kind)?.title ?? "Reminders";
+ ? (lists.find((l) => l.guid === listGuid)?.title ?? "Reminders")
+ : (SMART.find((s) => s.kind === (selection as { kind: SmartList }).kind)
+ ?.title ?? "Reminders");
const outstanding = items.filter((r) => !r.completedAt).length;
const colour = useMemo(
() => lists.find((l) => l.guid === listGuid)?.colour || "var(--gold)",
- [lists, listGuid]
+ [lists, listGuid],
);
return (
@@ -230,7 +279,9 @@ export function RemindersView() {
<button
key={s.kind}
className="rem-list"
- aria-current={selection.type === "smart" && selection.kind === s.kind}
+ aria-current={
+ selection.type === "smart" && selection.kind === s.kind
+ }
onClick={() => setSelection({ type: "smart", kind: s.kind })}
>
<span className="rem-list-name">{s.title}</span>
@@ -250,7 +301,9 @@ export function RemindersView() {
const title = e.target.value.trim();
setRenaming(null);
if (title && title !== list.title) {
- void listWrite(() => api.reminderListRename(list.guid, title));
+ void listWrite(() =>
+ api.reminderListRename(list.guid, title),
+ );
}
}}
onKeyDown={(e) => {
@@ -266,10 +319,15 @@ export function RemindersView() {
<button
className="rem-list"
aria-current={listGuid === list.guid}
- onClick={() => setSelection({ type: "list", guid: list.guid })}
+ onClick={() =>
+ setSelection({ type: "list", guid: list.guid })
+ }
onDoubleClick={() => setRenaming(list.guid)}
>
- <span className="dot" style={{ background: list.colour || "var(--gold)" }} />
+ <span
+ className="dot"
+ style={{ background: list.colour || "var(--gold)" }}
+ />
<span className="rem-list-name">{list.title}</span>
</button>
<button
@@ -284,7 +342,11 @@ export function RemindersView() {
aria-label={`Delete ${list.title}`}
onClick={() => {
// Deleting a list takes its reminders, so ask before doing it.
- if (window.confirm(`Delete "${list.title}" and everything in it?`)) {
+ if (
+ window.confirm(
+ `Delete "${list.title}" and everything in it?`,
+ )
+ ) {
void listWrite(() => api.reminderListDelete(list.guid));
}
}}
@@ -331,7 +393,11 @@ export function RemindersView() {
</div>
</header>
- {error && <p className="error" role="alert">{error}</p>}
+ {error && (
+ <p className="error" role="alert">
+ {error}
+ </p>
+ )}
{inList && (
<form className="rem-add" onSubmit={add}>
@@ -348,12 +414,16 @@ export function RemindersView() {
<ul className="rem-list-items">
{items.map((reminder) => {
- const due = reminder.dueAt === null ? null : dueLabel(reminder.dueAt);
+ const due =
+ reminder.dueAt === null ? null : dueLabel(reminder.dueAt);
const isOpen = openGuid === reminder.guid;
const repeat = repeatLabel(reminder);
const justMoved = moved?.guid === reminder.guid ? moved.text : null;
return (
- <li key={reminder.guid} className={reminder.completedAt ? "is-done" : undefined}>
+ <li
+ key={reminder.guid}
+ className={reminder.completedAt ? "is-done" : undefined}
+ >
<button
className="tick"
role="checkbox"
@@ -364,26 +434,43 @@ export function RemindersView() {
style={{ borderColor: colour }}
>
{reminder.completedAt && (
- <span className="tick-fill" style={{ background: colour }} />
+ <span
+ className="tick-fill"
+ style={{ background: colour }}
+ />
)}
</button>
<div className="rem-text">
- <input
- className="rem-title-edit"
- defaultValue={reminder.title}
- key={`${reminder.guid}-${reminder.title}`}
- aria-label={`Rename ${reminder.title}`}
- disabled={busyGuid === reminder.guid}
- onBlur={(e) => void rename(reminder, e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Enter") e.currentTarget.blur();
- if (e.key === "Escape") {
- e.currentTarget.value = reminder.title;
- e.currentTarget.blur();
- }
- }}
- />
+ <div className="rem-title-row">
+ {priorityMark(reminder.priority) && (
+ <span
+ className="rem-priority"
+ role="img"
+ aria-label={`${
+ PRIORITIES.find((p) => p.value === reminder.priority)
+ ?.label
+ } priority`}
+ >
+ {priorityMark(reminder.priority)}
+ </span>
+ )}
+ <input
+ className="rem-title-edit"
+ defaultValue={reminder.title}
+ key={`${reminder.guid}-${reminder.title}`}
+ aria-label={`Rename ${reminder.title}`}
+ disabled={busyGuid === reminder.guid}
+ onBlur={(e) => void rename(reminder, e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") e.currentTarget.blur();
+ if (e.key === "Escape") {
+ e.currentTarget.value = reminder.title;
+ e.currentTarget.blur();
+ }
+ }}
+ />
+ </div>
{reminder.notes && !isOpen && (
<span className="rem-notes">{reminder.notes}</span>
)}
@@ -403,12 +490,46 @@ export function RemindersView() {
{repeat}. Ticking it moves it to the next one.
</p>
)}
+ <label>
+ <span>Priority</span>
+ <select
+ value={reminder.priority}
+ disabled={busyGuid === reminder.guid}
+ onChange={(e) =>
+ void setPriority(reminder, Number(e.target.value))
+ }
+ >
+ {PRIORITIES.map((p) => (
+ <option key={p.value} value={p.value}>
+ {p.label}
+ </option>
+ ))}
+ </select>
+ </label>
+ <label>
+ <span>List</span>
+ <select
+ value={reminder.listGuid}
+ disabled={busyGuid === reminder.guid}
+ onChange={(e) =>
+ void moveToList(reminder, e.target.value)
+ }
+ >
+ {lists.map((l) => (
+ <option key={l.guid} value={l.guid}>
+ {l.title}
+ </option>
+ ))}
+ </select>
+ </label>
<label>
<span>Notes</span>
<textarea
defaultValue={reminder.notes ?? ""}
rows={2}
- onBlur={(e) => void setNotes(reminder, e.target.value)}
+ onBlur={(e) =>
+ void setNotes(reminder, e.target.value)
+ }
/>
</label>
</div>
@@ -423,12 +544,19 @@ export function RemindersView() {
) : (
<>
{repeat && (
- <span className="rem-repeat" role="img" aria-label={repeat} title={repeat}>
+ <span
+ className="rem-repeat"
+ role="img"
+ aria-label={repeat}
+ title={repeat}
+ >
↻
</span>
)}
{due && (
- <span className={`rem-due${due.overdue ? " overdue" : ""}`}>
+ <span
+ className={`rem-due${due.overdue ? " overdue" : ""}`}
+ >
{due.text}
</span>
)}
@@ -436,7 +564,11 @@ export function RemindersView() {
)}
<button
className={`rem-flag${reminder.flagged ? " on" : ""}`}
- aria-label={reminder.flagged ? `Unflag ${reminder.title}` : `Flag ${reminder.title}`}
+ aria-label={
+ reminder.flagged
+ ? `Unflag ${reminder.title}`
+ : `Flag ${reminder.title}`
+ }
aria-pressed={reminder.flagged}
disabled={busyGuid === reminder.guid}
onClick={() => flag(reminder)}
@@ -445,7 +577,11 @@ export function RemindersView() {
</button>
<button
className="rem-more"
- aria-label={isOpen ? `Close details for ${reminder.title}` : `Details for ${reminder.title}`}
+ aria-label={
+ isOpen
+ ? `Close details for ${reminder.title}`
+ : `Details for ${reminder.title}`
+ }
aria-expanded={isOpen}
onClick={() => setOpenGuid(isOpen ? null : reminder.guid)}
>
@@ -467,7 +603,11 @@ export function RemindersView() {
{loaded && items.length === 0 && !error && (
<p className="cal-empty">
- {inList ? (showDone ? "Nothing in this list." : "All done here.") : "Nothing here."}
+ {inList
+ ? showDone
+ ? "Nothing in this list."
+ : "All done here."
+ : "Nothing here."}
</p>
)}
</section>
diff --git a/src/styles/app.css b/src/styles/app.css
index e38f527..7c4bfef 100644
--- a/src/styles/app.css
+++ b/src/styles/app.css
@@ -680,6 +680,8 @@
.tick-fill { width: 10px; height: 10px; border-radius: var(--r-pill); }
.rem-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
+.rem-title-row { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
+.rem-title-row .rem-title-edit { flex: 1; min-width: 0; }
.rem-title { font-size: var(--t-13); }
.rem-notes {
font-size: var(--t-11);
@@ -1216,6 +1218,7 @@ textarea.note-text:disabled {
.rem-detail label > span { font-size: var(--t-11); color: var(--text-2); padding-top: 5px; }
.rem-detail input,
+.rem-detail select,
.rem-detail textarea {
font: inherit;
font-size: var(--t-13);
@@ -1229,8 +1232,20 @@ textarea.note-text:disabled {
}
.rem-detail input:focus,
+.rem-detail select:focus,
.rem-detail textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-ring); }
+/* Apple marks priority before the title, in its accent, and lets the marks pile up so
+ urgency is legible at a glance rather than needing to be read. */
+.rem-priority {
+ flex: none;
+ align-self: baseline;
+ color: var(--gold-strong);
+ font-size: var(--t-13);
+ font-weight: 650;
+ letter-spacing: -0.5px;
+}
+
/* Overdue is the one thing in this list that should catch the eye. */
.rem-due.overdue { color: var(--danger); }