New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new obsidian-readwise plugin #236
Add new obsidian-readwise plugin #236
Conversation
https://github.com/renehernandez/obsidian-readwise/releases/tag/0.0.1 https://github.com/renehernandez/obsidian-readwise/blob/03b2eca5db75e12604ce1719cb67864a5a322ad8/src/utils.ts#L4 https://github.com/renehernandez/obsidian-readwise/blob/03b2eca5db75e12604ce1719cb67864a5a322ad8/src/index.ts#L90 https://github.com/renehernandez/obsidian-readwise/blob/03b2eca5db75e12604ce1719cb67864a5a322ad8/src/settings.ts#L96 https://github.com/renehernandez/obsidian-readwise/blob/03b2eca5db75e12604ce1719cb67864a5a322ad8/src/index.ts#L14 |
|
@lishid Thanks for the feedback! I'll review/update accordingly |
|
Yup, looks like if you get rid of the secrets mechanism, you can remove all the NodeJS dependencies which means the plugin could even work on mobile. |
@lishid Are you suggesting that I declare My javascript/typescript skills are limited |
|
You're already using Moment.js from https://github.com/renehernandez/obsidian-readwise/blob/81f47a129be30922247b4a082bb3a2c90505cddf/src/status.ts#L69 That is the correct usage since Obsidian bundles a copy of moment.js. You don't need to add it to your dependencies. I'm not familiar with what you're using luxon for, but if it's just for manipulating and displaying dates then moment.js should suffice. |
|
I would suggest using unix timestamps throughout your code, and making it into a moment object only when you need to manipulate or display with |
|
MDN has some good docs: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage#example
Not that I know of other than our internal plugins. The benefit of using localStorage is that it's not directly accessible from the file system (It's stored in an encrypted blob inside the user's appdata), and that it's shared across multiple vaults. Though sharing it cross vault may be undesirable depending on what you're trying to do. |
I am not sure how easy would be (depending on how coupled/decoupled is the code), but I could benefit from having the internal plugins being open source. It would facilitate creating/following standard practices around plugin development |
|
I understand. It's still fairly coupled at the moment as it's sharing some basic tooling and UI components with the app, as well as using a completely different (older) plugin loading/hooking mechanism because we haven't had time to migrate them to the new public plugin format yet. |
|
@lishid I was reading about localStorage and I found out this alternative: https://github.com/sindresorhus/electron-store. Do you have any thoughts about it? |
|
@lishid And sorry for all the spammy questions. My JS/TS knowledge, specially with electron, is limited |
|
Also our mobile apps aren't electron based, so if you use electron APIs, your plugin would be unable to run on our mobile clients. |
|
@lishid As part of the localStorage implementation, I am thinking it would be nice to delete the token if the plugin is removed. I looked into the obsidian api definitions, but I don't see any hook for deletion? Is this supported? FYI: LocalStorage PR: renehernandez/obsidian-readwise#12 |
|
Ah you're right, there is no API for uninstall. The closest thing you can do is to do that in the onunload but I'm not fully sure of the implications. |
|
@lishid All the issues you raised have been resolved and released as part of version 0.0.2. Now the main.js file only weights ~250Kb. Thanks for all the help! |
|
https://github.com/renehernandez/obsidian-readwise/blob/72736bea12807a4e2918812a2c45145c42ce6a21/src/tokenManager.ts#L6 https://github.com/renehernandez/obsidian-readwise/blob/72736bea12807a4e2918812a2c45145c42ce6a21/src/index.ts#L128 https://github.com/renehernandez/obsidian-readwise/blob/72736bea12807a4e2918812a2c45145c42ce6a21/src/settings.ts#L8 https://github.com/renehernandez/obsidian-readwise/blob/72736bea12807a4e2918812a2c45145c42ce6a21/src/fileDoc.ts#L6 |
I have raised an issue about a new In the meantime, I'll write my join implementation to remove the usage of the Also, I don't see an easy way of detecting the platform ( |
|
@lishid Based on the comment above, I am ok to release the first version of the plugin as Desktop only and address it once the Obsidian API supports a |
|
Obsidian always use |
I missed that one! |
|
@lishid I have implemented the suggested fixes and I have released a new plugin version 0.0.3. Let me know if you have any other feedback |
|
I think we're at a point where this can be merged - just a couple of more small nits that aren't functionally important, but more code style related. https://github.com/renehernandez/obsidian-readwise/blob/214ceefd8e9bae6c7dd09939548f6eb8f05ab4d7/src/index.ts#L117 https://github.com/renehernandez/obsidian-readwise/blob/214ceefd8e9bae6c7dd09939548f6eb8f05ab4d7/src/tokenManager.ts#L9 |
|
@lishid Awesome. I added 2 new issues to track their implementation for a future 0.1.0 release. Thanks a lot for your feedback and guidance! |
[x] I am submitting a new Community Plugin
Repo URL
https://github.com/renehernandez/obsidian-readwise
Release Checklist
main.jsmanifest.jsonv)idin mymanifest.jsonmatches theidin thecommunity-plugins.jsonfile.