diff options
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} |
