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.

Drive: delete is instant and asks nothing, as Finder — it goes to Recently Deleted — and a refusal brings the item back with the reason

Yashwanth Kamireddi3bc78f1d5e1b
diff --git a/.uiverify/drive-delete.mjs b/.uiverify/drive-delete.mjs
new file mode 100644
index 0000000..6af7834
--- /dev/null
+++ b/.uiverify/drive-delete.mjs
@@ -0,0 +1,47 @@
+// Drive delete, as Finder: no question (it goes to Recently Deleted), gone at once though
+// Apple takes 1.5 s, and back with the reason if Apple refuses.
+import { engine } from "./engine.mjs";
+import { SERVICES, installStub, openScreen } from "./stub.mjs";
+const b = await engine.launch();
+let failures = 0;
+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };
+for (const refuse of [false, true]) {
+ const ctx = await b.newContext({ viewport: { width: 1200, height: 800 } });
+ await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null, driveFixture: true });
+ await ctx.addInitScript((refuse) => {
+ const wrap = () => {
+ const t = window.__TAURI_INTERNALS__;
+ if (!t || t.__slow) return;
+ const inner = t.invoke;
+ t.invoke = async (cmd, args) => {
+ if (cmd === "drive_delete") {
+ await new Promise((r) => setTimeout(r, 1500));
+ if (refuse) throw "iCloud didn't accept that change, so nothing was saved.";
+ }
+ return inner(cmd, args);
+ };
+ t.__slow = true;
+ };
+ wrap(); document.addEventListener("DOMContentLoaded", wrap);
+ }, refuse);
+ const page = await ctx.newPage();
+ let asked = false;
+ page.on("dialog", (d) => { asked = true; d.accept(); });
+ await page.goto("http://localhost:4173", { waitUntil: "networkidle" });
+ await openScreen(page, "iCloud Drive");
+ await page.waitForTimeout(300);
+ await page.getByRole("button", { name: "Actions for Semester Plan.pdf" }).click();
+ await page.getByRole("menuitem", { name: "Delete" }).click();
+ await page.waitForTimeout(150);
+ const row = () => page.locator(".drive-rows .drive-name", { hasText: "Semester Plan" }).count();
+ if (!refuse) {
+ ok(!asked, "Delete asks nothing: it goes to Recently Deleted");
+ ok((await row()) === 0, "the file leaves at once");
+ } else {
+ await page.waitForTimeout(1700);
+ ok((await row()) === 1 && (await page.locator('[role="alert"]').count()) === 1, "a refused delete brings the file back, with the reason");
+ }
+ await ctx.close();
+}
+await b.close();
+process.exitCode = failures ? 1 : 0;
diff --git a/check.sh b/check.sh
index cfe502b..460c3af 100755
--- a/check.sh
+++ b/check.sh
@@ -55,6 +55,7 @@ step "notes instant" node .uiverify/notes-instant.mjs
step "drive sort" node .uiverify/drive-sort.mjs
step "drive trash" node .uiverify/drive-trash.mjs
step "drive info" node .uiverify/drive-info.mjs
+step "drive delete" node .uiverify/drive-delete.mjs
# The same screens in WebKit, the engine Quince draws in. Chromium above catches most things;
# this catches what only WebKit does — pointer capture, blur on removal, its own layout.
diff --git a/src/screens/DriveView.tsx b/src/screens/DriveView.tsx
index 1a6033d..c7b6b46 100644
--- a/src/screens/DriveView.tsx
+++ b/src/screens/DriveView.tsx
@@ -438,29 +438,25 @@ export function DriveView() {
[refresh]
);
+ /**
+ * Delete, as Finder does it: no question, since it goes to Recently Deleted and comes back
+ * from there. The row leaves at once and stays gone — Apple's listing can carry it for a
+ * moment, and it used to flicker back — unless Apple refuses, when it returns and says why.
+ */
const remove = useCallback(
async (item: DriveItem) => {
- if (
- !window.confirm(
- `Move "${driveName(item)}" to Recently Deleted?${
- isContainer(item) ? " Everything inside it goes with it." : ""
- }`
- )
- ) {
- return;
- }
- setBusyGuid(item.drivewsid);
setError(null);
+ setGone((g) => new Set(g).add(item.drivewsid));
try {
await api.driveDelete(item.drivewsid);
- // Gone from the screen now, and kept gone: Apple's listing can still carry it for a
- // moment, and it flickered back before vanishing.
- setGone((g) => new Set(g).add(item.drivewsid));
await refresh();
} catch (e) {
+ setGone((g) => {
+ const next = new Set(g);
+ next.delete(item.drivewsid);
+ return next;
+ });
setError(messageOf(e));
- } finally {
- setBusyGuid(null);
}
},
[refresh]