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
Shared albums' grid pictures made ahead, so an album opens without its pictures flickering in; the test backend moves notes and lists a folder's own
Yashwanth Kamireddif85fbfa7b85c
diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex 470645e..0a4f28c 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -555,9 +555,15 @@ export function installStub({ screen, services, twoFactor, calendarFixture, note(window.__noteDeletes ??= []).push(args.guid);if (window.__slowDelete) await new Promise((r) => setTimeout(r, window.__slowDelete));return null;- case "note_move":+ // A move, kept as the library keeps it: in its new folder once it has gone through+ // (after `__slowMove` ms, Apple slow to answer). Left where it was, every read after a+ // slow move found the note back in its old folder — which the window then drew.+ case "note_move": {if (window.__slowMove) await new Promise((r) => setTimeout(r, window.__slowMove));+ const n = noteList.find((x) => x.guid === args?.guid);+ if (n) n.folderGuid = args.folderGuid ?? null;return null;+ }case "note_pin": {const n = noteList.find((x) => x.guid === args?.guid);if (n) n.pinned = args.pinned;@@ -607,7 +613,8 @@ export function installStub({ screen, services, twoFactor, calendarFixture, noteif (window.__lockedNote && !noteList.some((n) => n.guid === "nK"))noteList.unshift({ guid: "nK", folderGuid: "f1", title: "Bank", snippet: null, body: null,locked: true, editable: false, pinned: false, createdAt: null, modifiedAt: 1789400000, etag: null });- return !notesFixture ? [] : noteList.map((n) => ({ ...n }));+ // A folder's own notes, as the library answers (Library::notes_in); every note for none.+ return !notesFixture ? [] : noteList.filter((n) => args?.folderGuid == null || n.folderGuid === args.folderGuid).map((n) => ({ ...n }));case "note_attachment_info":if (/^A\d$/.test(String(args.id))) {(window.__infoAsks ??= []).push(args.id);diff --git a/crates/quince-core/src/shared.rs b/crates/quince-core/src/shared.rsindex acea9c8..1b7d9c2 100644--- a/crates/quince-core/src/shared.rs+++ b/crates/quince-core/src/shared.rs@@ -150,6 +150,27 @@ impl Library {.collect()}+ /// Every shared album's photos as the grid lays them out (for their pictures to be made+ /// ahead), newest first.+ pub fn shared_photo_shapes(&self) -> Result<Vec<crate::photos::PhotoShape>> {+ let mut stmt = self+ .conn+ .prepare("SELECT photo FROM shared_album_photos ORDER BY taken_at DESC, id")?;+ let rows = stmt.query_map([], |r| r.get::<_, String>(0))?;+ let mut out = Vec::new();+ for json in rows {+ let p: Photo = serde_json::from_str(&json?).map_err(json_error)?;+ out.push(crate::photos::PhotoShape {+ id: p.id,+ width: p.width,+ height: p.height,+ kind: p.kind,+ taken_at: p.taken_at,+ });+ }+ Ok(out)+ }+/// A photo to look at, copy or save: the library's own, or one in a shared album.pub fn photo_to_view(&self, id: &str) -> Result<Option<Photo>> {if let Some(p) = self.photo(id)? {diff --git a/src-tauri/src/photos.rs b/src-tauri/src/photos.rsindex 6c39055..08aaf38 100644--- a/src-tauri/src/photos.rs+++ b/src-tauri/src/photos.rs@@ -930,6 +930,37 @@ pub fn prepare(app: AppHandle) {tauri::async_runtime::spawn(async move {use futures_util::StreamExt;let fit_dir = crate::state_dir(&app).join("photos").join("fit");+ // Shared albums' photos first: Apple keeps no screen-sized picture of one (only a small+ // thumbnail and the original), so made as each tile came on screen, every tile fetched+ // its original while the album was open and flickered in one by one. They are few+ // (Apple caps an album at a few thousand): all of them, before the library's.+ let shared = app+ .state::<Data>()+ .0+ .read(quince_core::Library::shared_photo_shapes)+ .await+ .unwrap_or_default();+ if !shared.is_empty() {+ let dir = fit_dir.clone();+ let (wanted, _) = tauri::async_runtime::spawn_blocking(move || {+ wanted_steps(&shared, shown, 0, |id, step| {+ !dir.join(step.to_string()).join(&*cache_name(id)).exists()+ })+ })+ .await+ .unwrap_or_default();+ futures_util::stream::iter(wanted)+ .for_each_concurrent(4, |(id, step)| {+ let app = app.clone();+ async move {+ if PREPARING.load(std::sync::atomic::Ordering::SeqCst) != mine {+ return;+ }+ let _ = crate::cpu::ahead(fitted(&app, &id, step)).await;+ }+ })+ .await;+ }// The grid's photos a page at a time, each read beside a pass on a reader and made// before the next is read: what is held at once is one page, however large the// library (the whole of it, read as photos under the writer's lock, was 665 MB and