Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Photos: Shift-click widens from the photo last clicked, after a re-sort
Yashwanth Kamireddi66ee0b079e91
diff --git a/.uiverify/photos-anchor.mjs b/.uiverify/photos-anchor.mjsnew file mode 100644index 0000000..5daf3fd--- /dev/null+++ b/.uiverify/photos-anchor.mjs@@ -0,0 +1,35 @@+// Shift-click widens the selection from the photo last clicked, wherever the list has since+// put it: after the order is turned round the range ran from where that photo used to stand,+// and the photo clicked first could be left out of it.+//+// URL=http://localhost:4203 ENGINE=webkit node .uiverify/photos-anchor.mjs+import { engine, engineName } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";+const BASE = process.env.URL ?? "http://localhost:4173";+const b = await engine.launch();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${engineName} ${m}`); if (!p) failures++; };+const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null });+const page = await ctx.newPage();+page.on("pageerror", (e) => ok(false, `page error: ${e.message}`));+await page.goto(BASE, { waitUntil: "networkidle" });+await openScreen(page, "Photos");+await page.waitForTimeout(500);+const order = () => page.locator(".px-tile").evaluateAll((t) => t.map((x) => x.dataset.id).join(","));+const chosen = () => page.locator('.px-tile[aria-selected="true"]').evaluateAll((t) => t.map((x) => x.dataset.id).sort().join(","));+ok((await order()) === "p1,p2,p3,p4,p5", `newest first ${await order()}`);+await page.locator('.px-tile[data-id="p2"]').click();+await page.getByRole("button", { name: "Sort" }).click();+await page.locator(".row-menu").getByText("Oldest First").click();+await page.waitForTimeout(300);+ok((await order()) === "p5,p4,p3,p2,p1", `turned round ${await order()}`);+await page.locator('.px-tile[data-id="p1"]').click({ modifiers: ["Shift"] });+await page.waitForTimeout(150);+ok((await chosen()) === "p1,p2", `Shift-click selects from the photo clicked first to this one [${await chosen()}]`);+// Put back as it was for the next run.+await page.getByRole("button", { name: "Sort" }).click();+await page.locator(".row-menu").getByText("Newest First").click();+await b.close();+console.log(failures ? `\n${failures} FAILED` : "\nall passed");+process.exit(failures ? 1 : 0);diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsxindex efbde6c..36224e1 100644--- a/src/screens/PhotosView.tsx+++ b/src/screens/PhotosView.tsx@@ -732,6 +732,16 @@ export function PhotosView() {/** Photos selected in the grid, as on a Mac: a click selects, a double-click opens. */const [chosen, setChosen] = useState<Set<string>>(new Set());const anchor = useRef<number | null>(null);+ // The anchor is a place in the list, so it follows its photo when the list changes under it+ // (the order turned round, a sync's new photos above it): left where it was, Shift-click and+ // the arrows started from whichever photo had come to stand there.+ const anchorList = useRef(photos);+ if (anchorList.current !== photos) {+ const id = anchor.current !== null ? anchorList.current?.ids[anchor.current] : undefined;+ const at = id !== undefined && photos ? photos.indexOf(id) : -1;+ anchor.current = at >= 0 ? at : null;+ anchorList.current = photos;+ }const [uploads, setUploads] = useState<Map<string, UploadEvent>>(new Map());const [dropping, setDropping] = useState(false);const [menu, setMenu] = useState<{ at: { x: number; y: number; alignRight: boolean }; entries: MenuEntry[] } | null>(null);