Skip to content
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

use tauri store plugin to persist app data #29

Closed
opeolluwa opened this issue Mar 23, 2023 · 38 comments
Closed

use tauri store plugin to persist app data #29

opeolluwa opened this issue Mar 23, 2023 · 38 comments
Assignees
Labels
design & implementation The software architecture enhancement New feature or request good first issue Good for newcomers medium medium level of difficulty react/nextjs Rust

Comments

@opeolluwa
Copy link
Owner

opeolluwa commented Mar 23, 2023

Use the store plugin to persist app data. This will primarily contain the file transfer history and the user settings.

@opeolluwa opeolluwa added the enhancement New feature or request label Mar 23, 2023
@opeolluwa opeolluwa added good first issue Good for newcomers design & implementation The software architecture medium medium level of difficulty Rust react/nextjs labels Jun 9, 2023
@opeolluwa opeolluwa reopened this Jun 9, 2023
@opeolluwa opeolluwa changed the title Persist app data use tauri store plugin to persist app data Jun 9, 2023
@RPG-Alex
Copy link
Contributor

I would be interested in contributing and working on this issue. To clarify, the store plugin is not currently yet in use, and we would want to implement it for storing user data (settings, transfer history etc)?

@opeolluwa
Copy link
Owner Author

Hi Alex,
Thanks for reaching out! I appreciate your time and interest to contribute ❤️

Like you said, the feature has not been implemented at all.

It is intended to store the user settings (color theme, transfer history and anything required in the future).

I'm considering an embedded database, for the transfer history and storing the application settings such as theme, using the Tauri store plugin.

I'm open to discussing better approach to solving this and further clarification.

@RPG-Alex
Copy link
Contributor

Hi Alex, Thanks for reaching out! I appreciate your time and interest to contribute ❤️

Like you said, the feature has not been implemented at all.

It is intended to store the user settings (color theme, transfer history and anything required in the future).

I'm considering an embedded database, for the transfer history and storing the application settings such as theme, using the Tauri store plugin.

I'm open to discussing better approach to solving this and further clarification.

Sure! So should we discuss it here or via email or how to move forward? I have a few thoughts already but will start learning to work with the send-file codebase more and how to use the store plugin. The plugin looks pretty straightforward

@opeolluwa
Copy link
Owner Author

We can discuss it all here,

@RPG-Alex
Copy link
Contributor

Ok! I am ready to go, please feel free to assign the issue to me. I've forked and cloned the repo locally

@opeolluwa
Copy link
Owner Author

Great!

@opeolluwa
Copy link
Owner Author

I just push a major change, please sync the fork to avoid conflict in future PR

@RPG-Alex
Copy link
Contributor

Got it. Thanks for letting me know.

@opeolluwa
Copy link
Owner Author

You are welcome 🤗

@RPG-Alex
Copy link
Contributor

`Warn Waiting for your frontend dev server to start on http://localhost:1420/...
src/main.tsx:3:17 - error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './App.js' instead.

3 import App from './App.tsx'
~~~~~~~~~~~

tsconfig.json:11:5 - error TS5023: Unknown compiler option 'allowImportingTsExtensions'.

11 "allowImportingTsExtensions": true,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 2 errors in 2 files.

Errors Files
1 src/main.tsx:3
1 tsconfig.json:11
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error The "beforeDevCommand" terminated with a non-zero status code.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

I am getting this error message when I clone and run yarn tauri dev. Should I be using any flags or have I somehow messed up the setup?

@opeolluwa
Copy link
Owner Author

opeolluwa commented Jun 29, 2023

I notice the error in the CI too, and I'm currently looking into fixing it.
The error is coming from nesting a React application.

That said, the error does not occur at my end, I believe it could be a environment-related problem (eg Nde.js version

@opeolluwa
Copy link
Owner Author

@RPG-Alex
Copy link
Contributor

Thanks. I had tried reinstalling typescript.

My version:

tsc --version                                      06/29/2023 11:51:09 AM
Version 5.1.6

I also ran:
npm update -g

However the error persists. I''m going to research more on my end.

@opeolluwa
Copy link
Owner Author

Alright, Let me know when you see a fix. I'd look into it again

@opeolluwa
Copy link
Owner Author

Hi, @RPG-Alex any fix on the issue?

@RPG-Alex
Copy link
Contributor

So I have only one thing I suspect, as everything else has been fruitless. What version of yarn are you using?
try:

yarn --version

I am on arch linux, and am running: 1.22.19

Are you running the same version? I also had installed yarn from pacman, rather than through npm. I installed via npm but its the same version. I cannot figure out why it would be like this otherwise. I have a suspicion it is my yarn version but I'm not sure that makes sense. Nothing else has worked. Have tweaked the config jsons etc with no results

@opeolluwa
Copy link
Owner Author

I have yarn v 1.22.19.

Try deleting the browser directory, see if it works

@opeolluwa
Copy link
Owner Author

@opeolluwa
Copy link
Owner Author

Also, what version on Node.js do you use

@opeolluwa
Copy link
Owner Author

Also, what version on Node.js do you use

I think I fixed it,
The CI is not failing where it used to, I'll give it sometime to build the binary, using the CI, if all goes well. I'll notify you to sync the fork

@opeolluwa
Copy link
Owner Author

It's done! Everything should work fine now. Let me know if anything comes up

@RPG-Alex
Copy link
Contributor

Have synced, pulled, and executed. Can confirm this will now compile and run!
Haven't looked at your commits, what did you need to change to make it work?

PS: I will start working on this issue (#29) for persistent data tomorrow.

@opeolluwa
Copy link
Owner Author

I added "preinstall" to the scripts in package.json to install the dependencies of the browser directory

@opeolluwa
Copy link
Owner Author

Hi @RPG-Alex I made some designs review, In addition to using the store plugin to save some key-value pair of data, such as the color theme, can we work on an embedded SQLite database - something which can be bundled with the application binary, this will allow extending the application storage capacity for future use.

The Database created can be accessed on the UI using Tauri command...

Consider this function signature of suchlike

#[tauri::command]
pub fn save_record<T>(arg: T, table: &str) { ... }

A similar API can be implemented to fetch saved data.

Please, let me know if you have any questions

@RPG-Alex
Copy link
Contributor

RPG-Alex commented Jul 2, 2023

Hey @opeolluwa thanks for letting me know, I started looking at the code base now. For the database/data storage I think it will be better to map out everything that is needed for storage and define the data structures, then it should be easy to store in an SQL format and/or as JSON to a file etc, and access and modify. For now I do not have a clear idea of the exact values and where they are being set in the code base.

@opeolluwa
Copy link
Owner Author

The user file transfer history is what we'll persist in the database, the fields will be

  1. id - uuid
  2. file_name - string (ex. receipt.pdf)
  3. file_size - string (ex. 345kb)
  4. *transfer_type ( enum||string ) variant will be sent or received
  5. **date string ( ex Tuesday, July 23, 2023)

*string can be used, in place of enum. I think SQLite does not support enum

** The date would be parsed on the front end.

Other settings such as app data settings, language, color theme, e.t.c will be stored using the Tauri key-value store plugin.

@opeolluwa
Copy link
Owner Author

Hi, Alex, how is it going

@RPG-Alex
Copy link
Contributor

RPG-Alex commented Jul 7, 2023

@opeolluwa hello! I saw you updated the repository name. I'll make sure to use that rather than sendfile going forward.
Regarding the persistant app data, I have been looking through the existing functionality and user settings, and it appears that there isn't really an ability for a user to set anything quite yet. The settings tab doesn't do anything at the moment. So for this it may be better to hold off on this issue until there is user data to store, and then build off that. Let me know what you think

@opeolluwa
Copy link
Owner Author

opeolluwa commented Jul 7, 2023

hello! I saw you updated the repository name. I'll make sure to use that rather than sendfile going forward.

You can sync the repository from the forked one you have then pull the changes on your machine 💻
Instead of another fork or something.

Regarding the persistant app data, I have been looking through the existing functionality and user settings, and it appears that there isn't really an ability for a user to set anything quite yet.

Yes, it's as such because in a way, I'm spawn the page UI/UX, since there are no prior designs and I'm also waiting for the backend to know how the structure the components.

The settings tab doesn't do anything at the moment. So for this it may be better to hold off on this issue until there is user data to store, and then build off that. Let me know what you think

You can carry on, nonetheless. I'd appreciate that.

@RPG-Alex
Copy link
Contributor

RPG-Alex commented Jul 7, 2023

@opeolluwa I've pushed a transfer record file. Let me know your thoughts. Mostly on structure. Do you have experience working with Tauri's sqlite plugin? I do not and was scratching my head a bit as this will fail if I import this library and try to compile the application.

@JohnYepthomi
Copy link

Can I use the store to store data other than just the settings, essentially treating it like localstorage. or should i use the localstrage for that assuming its persistent. For small apps with not much data it would be overkill to use sql db's specially for data that are objects it would be convinient to use the persistent store plugin. I mean i'm already using it but i dont know the limits of it. Also, the mirror repo doesn't mention anything about removing entries..

Apologies if my question is unnecessary and naive.

@opeolluwa
Copy link
Owner Author

@opeolluwa I've pushed a transfer record file. Let me know your thoughts. Mostly on structure. Do you have experience working with Tauri's sqlite plugin? I do not and was scratching my head a bit as this will fail if I import this library and try to compile the application.

@RPG-Alex I reviewed the SQLite plugin. The computation is largely client side, all the backend require us to initialize the database, which I already did

@opeolluwa
Copy link
Owner Author

Can I use the store to store data other than just the settings, essentially treating it like localstorage. or should i use the localstrage for that assuming its persistent. For small apps with not much data it would be overkill to use sql db's specially for data that are objects it would be convinient to use the persistent store plugin. I mean i'm already using it but i dont know the limits of it. Also, the mirror repo doesn't mention anything about removing entries..

Apologies if my question is unnecessary and naive.

Hi @JohnYepthomi your questions are absolutely not naive.

The thing is, software should be built with scalability in mind. That's why we're opting for the Tauri store plugin to persist the user application settings and the SQLite plugin to persist the application data.

@RPG-Alex
Copy link
Contributor

@opeolluwa I've pushed a transfer record file. Let me know your thoughts. Mostly on structure. Do you have experience working with Tauri's sqlite plugin? I do not and was scratching my head a bit as this will fail if I import this library and try to compile the application.

@RPG-Alex I reviewed the SQLite plugin. The computation is largely client side, all the backend require us to initialize the database, which I already did

What do you mean client side? Are you talking about the React frontend?
If that isn't the direction you want to go, could you link me to the file where the work is that you have done? As I did not see it. And could you clarify how you want me to implement persistence with the database? As I'm not sure I understand now.

@opeolluwa
Copy link
Owner Author

Hi Alex, I looked up the SQLite plugin.

The heavy computation will the done in the React codebase.

Also, there isn't any more computation required on the backend than the Plugin initialization, which has been done.

@opeolluwa
Copy link
Owner Author

I think the work here is completed, since we already opted for the plugins rather than an embedded database.

I'd look up the SQLite plugin client side integration and fix it or push it out as a feature request.

Thank you so much for your time and effort. 💯

@opeolluwa
Copy link
Owner Author

If you'd be interested, I have another Open Source software being built in Rust which enable front end developers build functional full stack applications without having to write any backend code.

I'm currently refining the project scope for contribution.

It will be great to have you
https://github.com/opeolluwa/raccoon

@RPG-Alex
Copy link
Contributor

@opeolluwa Thanks for letting me know! I was on vacation, back now. If this issue is closed can you mark it closed? I will definitely checkout your other project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design & implementation The software architecture enhancement New feature or request good first issue Good for newcomers medium medium level of difficulty react/nextjs Rust
Projects
None yet
Development

No branches or pull requests

3 participants