question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] User scripts errors on Mobile (QuickAdd 0.5.0)

See original GitHub issue

Description

On two scripts, I’ve noticed errors when trying to launch them on mobile.

To reproduce

Script 1

When launching your Movie and Series script, I get the following error :

Error: Failed to load. Cleartext HTTP traffic to www.omdbapi.com not permitted

It seems that writing :

const API_URL = "https://www.omdbapi.com/";

Instead of :

const API_URL = "http://www.omdbapi.com/";

At line 5 of your script solves the problem ?

Script 2

When launching my Video game script, I get the following error :

TypeError: QuickAdd.app.vault.adapter.getBasePath is not a function

Apparently there is a problem with line 46 :

var basePath = QuickAdd.app.vault.adapter.getBasePath();

Maybe this does not exist on mobile ? How could I solve this issue so that it works both on mobile and still on PC ? I need to write some data to obsidian configuration folder and thus need vault path to navigate to it.

Script 3

My books script works perfectly fine on mobile (Android 12 - One UI 3.0) thanks to your 0.5.0 update !

Environment:

  • Device: Galaxy S20FE
  • OS: Android 12 - One UI 3.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chhoumanncommented, Feb 8, 2022

@Elaws Exactly that function is actually a bit harder, I believe. It’s not accessible from the window object, unlike app.

I just released a version which exposed the Obsidian API in scripts. Then you should be able to access the function like so:

module.exports = async (params) => {
    // params.obsidian.normalizePath
}
0reactions
Elawscommented, Feb 9, 2022

Wow @chhoumann, this is great : thank you very much !

Thanks to your help, I’ve finally been able to make script n°2 work on mobile, using the following (approximately) :

async function start(params, settings) {

[...]

var relativePath = params.app.vault.configDir;
savePath = params.obsidian.normalizePath(`${relativePath}/fileName.json`);

[...]

if(await params.app.vault.adapter.exists(savePath))
{ 
    userData = JSON.parse(await params.app.vault.adapter.read(savePath));
} 
else {
    [...]
    await params.app.vault.adapter.write(savePath, JSON.stringify(userData));
}

Not sure if this is clean, but it seems to work on Windows, Android 12 and iPad ^^

I thought I’d need full Obsidian API access to read/write file, but these functions are part of app.vault, which you already expose.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Failed to load user script /scripts ... - GitHub
Go to 'command palette'; Click on 'run QuickAdd'; Click on 'Add book'; Click on a book name; See error. Expected behavior. A file ......
Read more >
Better Android performance & custom sorting of files
Better Android performance & custom sorting of files. Themes with built-in color schemes! Plus, it's now easier to debug mobile plugins, ...
Read more >
How to get data from AWR1843 + Dca1000 configured using ...
Your current setup could be impacting the demo script from executing without error. Regards, Kyle. Up 0 True ...
Read more >
A script for Quickadd plugin to fetch book data into your vault ...
Due to QuickAdd update 0.5.0, this script now also works on mobile! 1 Like. jeroen ...
Read more >
Bug List - Bugzilla - Zimbra
ID△ Product△ Comp△ Assignee▽ Status▽ Changed△ 5513 ZCS Third Pa bugs_third_party NEW 2014‑09‑04 97955 ZCS WebDav bugs.webdav NEW 2015‑02‑20 83042 ZCS Mobile ‑ bugs.mobile.zimbra.mobile.sync NEW 2015‑02‑24...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found