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.

Photos: Recently Deleted as Photos keeps it — days left, Recover, Delete for good

Yashwanth Kamireddicfc93ae4038e
diff --git a/.uiverify/photos.mjs b/.uiverify/photos.mjs
index 521a1a2..532ad55 100644
--- a/.uiverify/photos.mjs
+++ b/.uiverify/photos.mjs
@@ -69,7 +69,7 @@ await page.locator(".px-source", { hasText: "Recently Deleted" }).click();
await page.waitForTimeout(200);
ok((await page.locator(".px-tile").count()) === 2, "the deleted photo is in Recently Deleted");
await page.locator(".px-tile").first().dblclick();
-await page.getByRole("button", { name: "Recover" }).click();
+await page.locator(".px-viewer").getByRole("button", { name: "Recover" }).click();
await page.waitForTimeout(300);
ok((await page.evaluate(() => window.__flags.at(-1))).on === false, "Recover brings it back");
await page.keyboard.press("Escape");
@@ -202,6 +202,27 @@ await page.waitForTimeout(400);
await page.keyboard.press("Escape");
await page.waitForTimeout(650);
+// Recently Deleted, as Photos keeps it: each photo with the time it has left (red in its last
+// days); Recover and Delete for what is selected, Delete All otherwise; Delete is for good
+// and asked first, in Photos' words.
+await page.locator(".px-source", { hasText: "Recently Deleted" }).click();
+await page.waitForTimeout(250);
+const left = page.locator(".px-tile .px-left");
+ok((await left.count()) === 1 && (await left.innerText()) === "2 days" && /is-soon/.test(await left.getAttribute("class")),
+ `a deleted photo shows its days left, red near the end "${await left.innerText()}"`);
+ok((await page.getByRole("button", { name: "Delete All" }).count()) === 1, "with nothing selected, the toolbar offers Delete All");
+await page.locator(".px-tile").first().click();
+ok((await page.locator(".px-word").allInnerTexts()).join() === "Recover,Delete", "with one selected, Recover and Delete");
+let asked = "";
+page.once("dialog", (d) => { asked = d.message(); void d.accept(); });
+await page.locator(".px-word", { hasText: /^Delete$/ }).click();
+await page.waitForTimeout(300);
+ok(/permanently/.test(asked) && /cannot be undone/.test(asked), `Delete asks first, in Photos' words "${asked.split("\n")[0]}"`);
+ok((await page.locator(".px-tile").count()) === 0 && (await page.evaluate(() => window.__flags.at(-1).flag)) === "expunged",
+ "and deletes it for good");
+await page.locator(".px-source", { hasText: "Library" }).click();
+await page.waitForTimeout(250);
+
const across = async () => page.locator(".px-grid").first().evaluate((g) => getComputedStyle(g).gridTemplateColumns.split(" ").length);
const before = await across();
await page.getByRole("button", { name: "Zoom In" }).click();
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjs
index 2cefc92..6a97c38 100644
--- a/.uiverify/stub.mjs
+++ b/.uiverify/stub.mjs
@@ -313,7 +313,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
favorite: false, hidden: false, deleted: false, deletedAt: null, subtype: 0, changeTag: null, ...extra });
const all = (window.__photos ??= [
P("p1", 1792500000, { favorite: true }), P("p2", 1792400000), P("p3", 1792300000, { kind: "video", duration: 12.4, uti: "public.mpeg-4", filename: "clip.mp4" }),
- P("p4", 1789900000), P("p5", 1789800000), P("p6", 1789700000, { deleted: true, deletedAt: 1792600000 }),
+ P("p4", 1789900000), P("p5", 1789800000), P("p6", 1789700000, { deleted: true, deletedAt: 1792600000, expungeAt: Math.floor(Date.now() / 1000) + 2 * 86400 + 600 }),
]);
const live = all.filter((p) => !p.deleted && !p.hidden);
const views = {
@@ -357,6 +357,7 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note
if (p) {
if (args.flag === "favorite") p.favorite = args.on;
if (args.flag === "hidden") p.hidden = args.on;
+ if (args.flag === "expunged") window.__photos.splice(window.__photos.indexOf(p), 1);
if (args.flag === "deleted") { p.deleted = args.on; p.deletedAt = args.on ? 1792700000 : null; }
}
return p;
diff --git a/crates/quince-core/src/photos.rs b/crates/quince-core/src/photos.rs
index fd5d734..dff8034 100644
--- a/crates/quince-core/src/photos.rs
+++ b/crates/quince-core/src/photos.rs
@@ -64,6 +64,9 @@ pub struct Photo {
pub deleted: bool,
/// When it was deleted: Photos counts its 30 days from here.
pub deleted_at: Option<i64>,
+ /// In Recently Deleted: when Apple deletes it for good, unix seconds (`dateExpunged`).
+ #[serde(default)]
+ pub expunge_at: Option<i64>,
/// Photos' subtype: 1 and 3 mark screenshots and the like (`assetSubtypeV2`).
pub subtype: i64,
/// The asset's change tag, for writing back to it.
@@ -111,7 +114,7 @@ pub enum View {
}
const COLUMNS: &str = "id, master, taken_at, added_at, kind, width, height, duration, filename, \
- size, uti, favorite, hidden, deleted, deleted_at, subtype, change_tag";
+ size, uti, favorite, hidden, deleted, deleted_at, subtype, change_tag, expunge_at";
fn row_to_photo(r: &rusqlite::Row<'_>) -> rusqlite::Result<Photo> {
Ok(Photo {
@@ -132,6 +135,7 @@ fn row_to_photo(r: &rusqlite::Row<'_>) -> rusqlite::Result<Photo> {
deleted_at: r.get(14)?,
subtype: r.get(15)?,
change_tag: r.get(16)?,
+ expunge_at: r.get(17)?,
})
}
@@ -143,8 +147,8 @@ impl Library {
let mut stmt = tx.prepare(
"INSERT INTO photos (id, master, taken_at, added_at, kind, width, height, duration,
filename, size, uti, favorite, hidden, deleted, deleted_at,
- subtype, change_tag)
- VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17)
+ subtype, change_tag, expunge_at)
+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18)
ON CONFLICT(id) DO UPDATE SET
master = excluded.master, taken_at = excluded.taken_at,
added_at = excluded.added_at, kind = excluded.kind, width = excluded.width,
@@ -152,7 +156,8 @@ impl Library {
filename = excluded.filename, size = excluded.size, uti = excluded.uti,
favorite = excluded.favorite, hidden = excluded.hidden,
deleted = excluded.deleted, deleted_at = excluded.deleted_at,
- subtype = excluded.subtype, change_tag = excluded.change_tag",
+ subtype = excluded.subtype, change_tag = excluded.change_tag,
+ expunge_at = excluded.expunge_at",
)?;
for p in photos {
stmt.execute(params![
@@ -172,7 +177,8 @@ impl Library {
i64::from(p.deleted),
p.deleted_at,
p.subtype,
- p.change_tag
+ p.change_tag,
+ p.expunge_at
])?;
}
}
@@ -445,6 +451,7 @@ mod tests {
deleted_at: None,
subtype: 0,
change_tag: None,
+ expunge_at: None,
}
}
diff --git a/crates/quince-core/src/schema.rs b/crates/quince-core/src/schema.rs
index 6aa9d71..06252c2 100644
--- a/crates/quince-core/src/schema.rs
+++ b/crates/quince-core/src/schema.rs
@@ -439,4 +439,10 @@ pub const MIGRATIONS: &[&str] = &[
) STRICT;
UPDATE sync_state SET token = NULL WHERE service = 'photos';
"#,
+ // When a photo in Recently Deleted goes for good, as Apple counts it; Photos is read
+ // again so every deleted photo has it.
+ r#"
+ ALTER TABLE photos ADD COLUMN expunge_at INTEGER;
+ UPDATE sync_state SET token = NULL WHERE service = 'photos';
+ "#,
];
diff --git a/crates/quince-icloud/src/photos.rs b/crates/quince-icloud/src/photos.rs
index a85f632..a858de9 100644
--- a/crates/quince-icloud/src/photos.rs
+++ b/crates/quince-icloud/src/photos.rs
@@ -158,6 +158,9 @@ pub fn photo_of(asset: &Value, master: &Value) -> Option<Photo> {
.filter(|&d| d == 1)
.and(millis(asset, "recordModificationDate")),
subtype: field::int(asset, "assetSubtypeV2").unwrap_or(0),
+ expunge_at: (field::int(asset, "isDeleted") == Some(1))
+ .then(|| millis(asset, "dateExpunged"))
+ .flatten(),
change_tag: asset
.get("recordChangeTag")
.and_then(Value::as_str)
@@ -180,6 +183,11 @@ fn with_asset(mut p: Photo, asset: &Value) -> Photo {
} else {
None
};
+ p.expunge_at = if p.deleted {
+ millis(asset, "dateExpunged").or(p.expunge_at)
+ } else {
+ None
+ };
p.change_tag = asset
.get("recordChangeTag")
.and_then(Value::as_str)
@@ -228,6 +236,12 @@ pub fn apply(
masters.insert(name, r);
}
}
+ // Deleted for good stays a record at Apple, marked expunged: it is gone here.
+ Some("CPLAsset") if field::int(r, "isExpunged") == Some(1) => {
+ if let Some(name) = field::record_name(r) {
+ gone.push(name);
+ }
+ }
Some("CPLAsset") => assets.push(r),
Some("CPLContainerRelation") => {
let album = field::string(r, "containerId");
@@ -338,6 +352,7 @@ pub async fn set_flag(
Flag::Favorite => "isFavorite",
Flag::Deleted => "isDeleted",
Flag::Hidden => "isHidden",
+ Flag::Expunged => "isExpunged",
};
client
.update_record(
@@ -506,6 +521,8 @@ pub enum Flag {
Favorite,
Deleted,
Hidden,
+ /// Deleted for good, from Recently Deleted: `isExpunged: 1`. It cannot be undone.
+ Expunged,
}
/// One master's links, read from Apple now: for a picture whose cached link expired, or one
@@ -679,4 +696,34 @@ mod tests {
"the photos stay in the library"
);
}
+
+ /// A photo deleted for good stays a record at Apple, marked `isExpunged`; the library
+ /// lets it go rather than keep it in Recently Deleted.
+ #[test]
+ fn an_expunged_photo_goes() {
+ let mut lib = quince_core::Library::in_memory().unwrap();
+ let pass = |records, incremental| PhotosFetch {
+ records,
+ token: Some("T".into()),
+ incremental,
+ complete: true,
+ };
+ apply(
+ &mut lib,
+ pass(vec![master(), asset(json!({"isDeleted": 1}))], false),
+ )
+ .unwrap();
+ assert_eq!(
+ lib.photos(quince_core::photos::View::RecentlyDeleted)
+ .unwrap()
+ .len(),
+ 1
+ );
+ apply(
+ &mut lib,
+ pass(vec![asset(json!({"isDeleted": 1, "isExpunged": 1}))], true),
+ )
+ .unwrap();
+ assert!(lib.photo("A1").unwrap().is_none());
+ }
}
diff --git a/probe/examples/photos_expunge.rs b/probe/examples/photos_expunge.rs
new file mode 100644
index 0000000..1b6269a
--- /dev/null
+++ b/probe/examples/photos_expunge.rs
@@ -0,0 +1,60 @@
+//! Live: delete for good, through Quince's own set_flag, photos already in Recently Deleted —
+//! only the test images this project uploaded. Refuses anything not deleted or not named
+//! quince-upload-test.jpg, and reads each back from Apple after.
+use anyhow::{anyhow, Result};
+use base64::Engine;
+use quince_icloud::photos::{self, Flag, CONTAINER, ZONE};
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ let dir = std::path::PathBuf::from(std::env::var("HOME")?).join(".local/share/quince-probe");
+ let mut client = quince_auth::Client::new(&dir)?;
+ if !client.resume().await? {
+ return Err(anyhow!("no session"));
+ }
+ let ck = client
+ .session()
+ .service_url("ckdatabasews")
+ .ok_or_else(|| anyhow!("no ck"))?;
+ let (http, p) = (client.http().clone(), client.service_params());
+ let zc = quince_icloud::cloudkit::ZoneClient::new(&http, &ck, CONTAINER, p.clone());
+ for asset in std::env::args().skip(1) {
+ let a = zc
+ .lookup_record(ZONE, &asset)
+ .await?
+ .ok_or_else(|| anyhow!("{asset}: gone"))?;
+ let master = a
+ .pointer("/fields/masterRef/value/recordName")
+ .and_then(|v| v.as_str())
+ .unwrap_or_default();
+ let m = zc.lookup_record(ZONE, master).await?;
+ let name = m
+ .as_ref()
+ .and_then(|m| {
+ m.pointer("/fields/filenameEnc/value")
+ .and_then(|v| v.as_str())
+ })
+ .and_then(|v| base64::engine::general_purpose::STANDARD.decode(v).ok())
+ .map(|b| String::from_utf8_lossy(&b).into_owned())
+ .unwrap_or_default();
+ let deleted = a
+ .pointer("/fields/isDeleted/value")
+ .and_then(|v| v.as_i64())
+ == Some(1);
+ if !deleted || name != "quince-upload-test.jpg" {
+ println!("{asset}: skipped ({name}, deleted={deleted})");
+ continue;
+ }
+ let tag = a.get("recordChangeTag").and_then(|t| t.as_str());
+ photos::set_flag(&http, &ck, p.clone(), &asset, tag, Flag::Expunged, true).await?;
+ let after = zc.lookup_record(ZONE, &asset).await?;
+ println!(
+ "{asset} ({name}): after = {}",
+ after.map_or("record gone".into(), |r| format!(
+ "isExpunged={:?}",
+ r.pointer("/fields/isExpunged/value")
+ ))
+ );
+ }
+ Ok(())
+}
diff --git a/probe/examples/photos_peek.rs b/probe/examples/photos_peek.rs
new file mode 100644
index 0000000..9b5a04f
--- /dev/null
+++ b/probe/examples/photos_peek.rs
@@ -0,0 +1,31 @@
+//! Live, read-only: one asset's date fields as Apple holds them.
+use anyhow::{anyhow, Result};
+#[tokio::main]
+async fn main() -> Result<()> {
+ let asset = std::env::args().nth(1).ok_or_else(|| anyhow!("asset id"))?;
+ let dir = std::path::PathBuf::from(std::env::var("HOME")?).join(".local/share/quince-probe");
+ let mut client = quince_auth::Client::new(&dir)?;
+ if !client.resume().await? {
+ return Err(anyhow!("no session"));
+ }
+ let ck = client
+ .session()
+ .service_url("ckdatabasews")
+ .ok_or_else(|| anyhow!("no ck"))?;
+ let zc = quince_icloud::cloudkit::ZoneClient::new(
+ client.http(),
+ &ck,
+ quince_icloud::photos::CONTAINER,
+ client.service_params(),
+ );
+ let r = zc
+ .lookup_record(quince_icloud::photos::ZONE, &asset)
+ .await?
+ .ok_or_else(|| anyhow!("gone"))?;
+ for (k, v) in r["fields"].as_object().unwrap() {
+ if k.contains("ate") || k.starts_with("is") {
+ println!("{k} = {}", v["value"]);
+ }
+ }
+ Ok(())
+}
diff --git a/src-tauri/src/photos.rs b/src-tauri/src/photos.rs
index 1bc382a..d61a5d4 100644
--- a/src-tauri/src/photos.rs
+++ b/src-tauri/src/photos.rs
@@ -384,8 +384,8 @@ async fn album_of(data: &State<'_, Data>, id: &str) -> UiResult<quince_core::pho
.ok_or_else(|| "That album is no longer there.".into())
}
-/// Favorite, Delete (to Recently Deleted, never for good) or Recover a photo, as icloud.com
-/// does it: the asset's one field updated against its change tag. The library takes Apple's
+/// Favorite, Hide, Delete (to Recently Deleted), Recover, or — from Recently Deleted only —
+/// delete for good, as icloud.com does it: the asset's one field updated against its change tag. The library takes Apple's
/// answer at once, so every view shows it without waiting for the next pass.
#[tauri::command]
pub async fn photo_set_flag(
@@ -403,6 +403,11 @@ pub async fn photo_set_flag(
.photo(&id)
.map_err(|e| e.to_string())?
.ok_or("That photo is no longer in the library.")?;
+ // Deleting for good is only ever from Recently Deleted, and only ever on: there is no
+ // taking it back, so nothing else may reach it.
+ if flag == quince_icloud::photos::Flag::Expunged && (!on || !photo.deleted) {
+ return Err("Only a photo in Recently Deleted can be deleted for good.".into());
+ }
let (http, root, params) = crate::cloudkit_context(&auth).await?;
let answer = quince_icloud::photos::set_flag(
&http,
@@ -422,6 +427,23 @@ pub async fn photo_set_flag(
quince_icloud::photos::Flag::Deleted => {
updated.deleted = on;
updated.deleted_at = on.then(|| jiff::Timestamp::now().as_second());
+ // Apple's own date for when it goes for good, or its thirty days until it says.
+ updated.expunge_at = on.then(|| {
+ answer
+ .pointer("/fields/dateExpunged/value")
+ .and_then(serde_json::Value::as_i64)
+ .map_or(jiff::Timestamp::now().as_second() + 30 * 86_400, |ms| {
+ ms / 1000
+ })
+ });
+ }
+ quince_icloud::photos::Flag::Expunged => {
+ data.0
+ .lock()
+ .await
+ .forget_photos(std::slice::from_ref(&id))
+ .map_err(|e| e.to_string())?;
+ return Ok(updated);
}
}
updated.change_tag = answer
diff --git a/src/lib/ipc.ts b/src/lib/ipc.ts
index e62d847..ef7fbb1 100644
--- a/src/lib/ipc.ts
+++ b/src/lib/ipc.ts
@@ -95,7 +95,7 @@ export const api = {
/** A video (or a Live Photo's moving part) opened in this computer's own player. */
photoPlay: (id: string) => invoke<void>("photo_play", { id }),
/** Favorite, Delete (to Recently Deleted) or Recover; answers the photo as Apple now has it. */
- photoSetFlag: (id: string, flag: "favorite" | "deleted" | "hidden", on: boolean) =>
+ photoSetFlag: (id: string, flag: "favorite" | "deleted" | "hidden" | "expunged", on: boolean) =>
invoke<Photo>("photo_set_flag", { id, flag, on }),
/** The original saved to Downloads; answers where. */
photoDownload: (id: string) => invoke<string>("photo_download", { id }),
@@ -578,6 +578,8 @@ export type Photo = {
hidden: boolean;
deleted: boolean;
deletedAt: number | null;
+ /** In Recently Deleted: when Apple deletes it for good, unix seconds. */
+ expungeAt?: number | null;
subtype: number;
changeTag: string | null;
};
diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsx
index 23df53f..89ba4fa 100644
--- a/src/screens/PhotosView.tsx
+++ b/src/screens/PhotosView.tsx
@@ -62,7 +62,19 @@ const pickedWords = (list: Photo[]) => {
return `${n.toLocaleString()} ${n === 1 ? noun : `${noun}s`} Selected`;
};
-type Flag = "favorite" | "deleted" | "hidden";
+type Flag = "favorite" | "deleted" | "hidden" | "expunged";
+
+/**
+ * How long a photo in Recently Deleted has left, in Photos' words: "29 days left" (or, on a
+ * tile, "29 days"), then hours, then minutes; red under four days, as Photos turns it.
+ */
+const timeLeft = (p: Photo, compact: boolean) => {
+ if (!p.expungeAt) return null;
+ const ms = Math.max(0, p.expungeAt * 1000 - Date.now());
+ const [unit, size] = ms >= 86_400_000 ? ["day", 86_400_000] : ms >= 3_600_000 ? ["hour", 3_600_000] : ["minute", 60_000];
+ const n = Math.max(1, Math.floor(ms / size));
+ return { words: `${n} ${unit}${n === 1 ? "" : "s"}${compact ? "" : " left"}`, soon: ms < 4 * 86_400_000 };
+};
const clock = (s: number | null) => {
if (!s) return "";
@@ -332,6 +344,7 @@ export function PhotosView() {
else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "l" && current && view !== "recentlyDeleted") void change(current, "hidden", view !== "hidden");
else if ((e.key === "Delete" || e.key === "Backspace") && current && album) void removeFrom([current]);
else if ((e.key === "Delete" || e.key === "Backspace") && current && view !== "recentlyDeleted") void change(current, "deleted", true);
+ else if ((e.key === "Delete" || e.key === "Backspace") && current && view === "recentlyDeleted" && !album) void change(current, "expunged", true);
else return;
e.preventDefault();
};
@@ -356,6 +369,15 @@ export function PhotosView() {
) {
return;
}
+ // For good, in Photos' words: it cannot be undone.
+ if (
+ flag === "expunged" &&
+ !window.confirm(
+ `${n === 1 ? "Are you sure you want to delete this item permanently?" : `Are you sure you want to delete these ${n} items permanently?`}\n\nThis action cannot be undone.`,
+ )
+ ) {
+ return;
+ }
// Hiding asks too, in Photos' words: where the photos go.
if (
flag === "hidden" && on &&
@@ -367,7 +389,8 @@ export function PhotosView() {
const ids = new Set(list.map((p) => p.id));
// Which changes take a photo out of the view it is in.
const leaves =
- album ? flag !== "favorite" && on
+ flag === "expunged" ? true
+ : album ? flag !== "favorite" && on
: flag === "deleted" ? (on ? view !== "recentlyDeleted" : view === "recentlyDeleted")
: flag === "hidden" ? (on ? view !== "hidden" : view === "hidden")
: !on && view === "favorites";
@@ -566,6 +589,7 @@ export function PhotosView() {
} else if ((e.key === "Delete" || e.key === "Backspace") && selected.length) {
if (album) void removeFrom(selected);
else if (view !== "recentlyDeleted") void changeAll(selected, "deleted", true);
+ else void changeAll(selected, "expunged", true);
} else if (ctrl && e.key.toLowerCase() === "l" && selected.length && view !== "recentlyDeleted") {
// ⌘L in Photos: hide, or in Hidden, unhide.
void changeAll(selected, "hidden", view !== "hidden");
@@ -600,7 +624,11 @@ export function PhotosView() {
at,
entries:
view === "recentlyDeleted" && !album
- ? [{ label: `Recover ${n} Photos`, run: () => void changeAll(group, "deleted", false) }]
+ ? [
+ { label: `Recover ${n} Items`, run: () => void changeAll(group, "deleted", false) },
+ null,
+ { label: `Delete ${n} Items`, danger: true, run: () => void changeAll(group, "expunged", true) },
+ ]
: [
{ label: anyPlain ? "Favorite" : "Unfavorite", run: () => void changeAll(group, "favorite", anyPlain) },
null,
@@ -618,7 +646,11 @@ export function PhotosView() {
}
const entries: MenuEntry[] =
view === "recentlyDeleted" && !album
- ? [{ label: "Recover", run: () => void change(p, "deleted", false) }]
+ ? [
+ { label: "Recover", run: () => void change(p, "deleted", false) },
+ null,
+ { label: "Delete", danger: true, run: () => void change(p, "expunged", true) },
+ ]
: [
{ label: p.favorite ? "Unfavorite" : "Favorite", run: () => void change(p, "favorite", !p.favorite) },
{ label: "Download", run: () => void download(p) },
@@ -913,6 +945,26 @@ export function PhotosView() {
(here ?? span) && <p className="px-span">{here ?? span}</p>
)}
</div>
+ {view === "recentlyDeleted" && !album && photos && photos.length > 0 && (
+ // Recently Deleted's own toolbar, in Photos' words: Recover and Delete for what is
+ // selected, Delete All when nothing is.
+ <div className="px-capsule px-words">
+ {selected.length > 0 ? (
+ <>
+ <button className="px-word" onClick={() => void changeAll(selected, "deleted", false)}>
+ Recover
+ </button>
+ <button className="px-word is-danger" onClick={() => void changeAll(selected, "expunged", true)}>
+ Delete
+ </button>
+ </>
+ ) : (
+ <button className="px-word is-danger" onClick={() => void changeAll(photos, "expunged", true)}>
+ Delete All
+ </button>
+ )}
+ </div>
+ )}
<div className="px-capsule" role="group" aria-label="Zoom">
<button className="px-cap" aria-label="Zoom Out" title="Zoom Out (Ctrl −)" disabled={zoom === 0} onClick={() => setZoom((z) => Math.max(0, z - 1))}>
<Minus size={15} strokeWidth={2.2} aria-hidden="true" />
@@ -981,6 +1033,9 @@ export function PhotosView() {
{clock(photo.duration)}
</span>
)}
+ {view === "recentlyDeleted" && !album && timeLeft(photo, true) && (
+ <span className={`px-badge px-left${timeLeft(photo, true)!.soon ? " is-soon" : ""}`}>{timeLeft(photo, true)!.words}</span>
+ )}
{photo.favorite && (
<Heart className="px-heart" size={13} strokeWidth={0} fill="currentColor" aria-label="Favorite" />
)}
@@ -1003,13 +1058,22 @@ export function PhotosView() {
</div>
<div className="px-viewer-when">
<strong>{new Date(shown.takenAt * 1000).toLocaleDateString(undefined, { dateStyle: "long" })}</strong>
- <span>{new Date(shown.takenAt * 1000).toLocaleTimeString(undefined, { timeStyle: "short" })}</span>
+ {view === "recentlyDeleted" && !album && timeLeft(shown, false) ? (
+ <span className={timeLeft(shown, false)!.soon ? "is-soon" : undefined}>{timeLeft(shown, false)!.words}</span>
+ ) : (
+ <span>{new Date(shown.takenAt * 1000).toLocaleTimeString(undefined, { timeStyle: "short" })}</span>
+ )}
</div>
<div className="px-capsule">
{view === "recentlyDeleted" && !album ? (
- <button className="px-cap" aria-label="Recover" title="Recover" onClick={() => void change(shown, "deleted", false)}>
- <RotateCcw size={17} />
- </button>
+ <>
+ <button className="px-cap" aria-label="Recover" title="Recover" onClick={() => void change(shown, "deleted", false)}>
+ <RotateCcw size={17} />
+ </button>
+ <button className="px-cap" aria-label="Delete Permanently" title="Delete permanently (Delete)" onClick={() => void change(shown, "expunged", true)}>
+ <Trash2 size={17} />
+ </button>
+ </>
) : (
<>
<button
diff --git a/src/styles/photos.css b/src/styles/photos.css
index b130215..13f27f8 100644
--- a/src/styles/photos.css
+++ b/src/styles/photos.css
@@ -139,6 +139,30 @@
.px-cap:disabled { color: var(--text-3); opacity: 0.55; }
.px-cap:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: -2px; }
+/* Words in a capsule — Recently Deleted's Recover, Delete, Delete All — as Photos sets them. */
+.px-words { padding: 0 4px; }
+.px-word {
+ height: 34px;
+ padding: 0 12px;
+ border: 0;
+ border-radius: 17px;
+ background: transparent;
+ color: var(--accent);
+ font: inherit;
+ font-size: var(--t-13);
+ font-weight: 600;
+ cursor: default;
+ transition: background-color 120ms ease, transform 160ms var(--spring-quick);
+}
+.px-word.is-danger { color: var(--danger); }
+.px-word:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
+.px-word:active { transform: scale(0.95); }
+.px-word:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: -2px; }
+/* Time left on a deleted photo's tile; red in its last days. */
+.px-badge.px-left { left: 6px; right: auto; }
+.px-badge.px-left.is-soon { color: #ff6961; }
+.px-viewer-when .is-soon { color: var(--danger); }
+
.px-tally {
margin: 18px 0 8px;
color: var(--text-2);