mProjectsCode / obsidian-js-engine-plugin

https://www.moritzjung.dev/obsidian-js-engine-plugin-docs/
GNU General Public License v3.0
73 stars 5 forks source link

fix mobile importJs #1

Closed Krakor92 closed 1 year ago

Krakor92 commented 1 year ago

I'm gonna rewrite here what I've written on Discord to have the context of this PR:

DataAdapter.getResourcePath method doesn't have the same behavior on computer and on mobile. While they both returns the absolute path of the resource passed in parameter, the desktop version append a ?mtime suffix at the end, which correspond to the file's modified time. This let the import(fullPath) in API.ts know when the resource can be cached hit or not. Unfortunately since this suffix isn't added on mobile (I'd be interested to know the reason behind this), the import always return the cached version of the file. Thus, only a full reload of the app flush the cache on mobile (I guess)

I think that using getFirstLinkpathDest, to retrieve a TFile of the imported script is the cleanest workaround. That way I can append the TFile.mtime directly at the end of path to optimize cache hits.