diff options
| author | Christopher Warner <cwarner@kernelcode.com> | 2026-10-10 19:02:13 -0400 |
|---|---|---|
| committer | Christopher Warner <cwarner@kernelcode.com> | 2026-10-10 19:02:13 -0400 |
| commit | fb9d23c213e2cdfdeddb94ed66459cc13b5d339e (patch) | |
| tree | dd2669c4ac5c7d0b386f09a37822cd8826c544ec /src | |
| parent | 41d0d57b0897bf1d8fd4db7f16f5ce454c3b74b9 (diff) | |
| download | iphone-notes-fb9d23c213e2cdfdeddb94ed66459cc13b5d339e.tar.gz iphone-notes-fb9d23c213e2cdfdeddb94ed66459cc13b5d339e.tar.bz2 iphone-notes-fb9d23c213e2cdfdeddb94ed66459cc13b5d339e.tar.xz iphone-notes-fb9d23c213e2cdfdeddb94ed66459cc13b5d339e.zip | |
fix(browser): invoke async NotesApp helpers as real JS functions
chromiumoxide misclassifies `async () =>` as an expression, so create/update
never ran. Use `async function ()` and wait for notes (not just folders).
Co-authored-by: Cursor <cursoragent@cursor.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/browser.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/browser.rs b/src/browser.rs index 2cecf5a..aee77ec 100644 --- a/src/browser.rs +++ b/src/browser.rs @@ -153,9 +153,11 @@ async fn notes_ready(page: &Page) -> Result<bool> { if (!dm) return { ready: false }; const notes = dm.allNotes || dm.__CW__allNotes; const folders = dm.allFolders || dm.__CW__allFolders || dm.folders; - const n = notes?.length || 0; - const f = folders?.length || 0; - return { ready: n > 0 || f > 0 }; + const n = (typeof notes?.get === "function" && typeof notes.get("length") === "number") + ? notes.get("length") + : (notes?.length || 0); + // Need at least one note so Note.create* is reachable via sample.constructor + return { ready: n > 0 }; }"#, ) .await? @@ -274,8 +276,10 @@ async fn create_via_notes_app(page: &Page, title: &str, body: &str) -> Result<Cr let paras_js = paragraphs_json(title, body)?; let helpers = note_list_helpers_js(); let styles = style_helpers_js(); + // Use `async function ()` (not `async () =>`) so chromiumoxide detects a JS + // function. Arrow form is misclassified as an expression and never invoked. let expr = format!( - r#"async () => {{ + r#"async function () {{ const text = {text_js}; const paras = {paras_js}; {helpers} @@ -335,8 +339,9 @@ async fn update_via_notes_app(page: &Page, match_title: &str, title: &str, body: let match_js = serde_json::to_string(match_title)?; let helpers = note_list_helpers_js(); let styles = style_helpers_js(); + // Use `async function ()` (not `async () =>`) — see create_via_notes_app. let expr = format!( - r#"async () => {{ + r#"async function () {{ const text = {text_js}; const matchTitle = {match_js}; {helpers} |
