opeolluwa / filesync

Quickly and securely share files from Windows, Linux, Mac to Android devices using wifi.
MIT License
98 stars 19 forks source link

use tauri store plugin to persist app data #29

Closed opeolluwa closed 1 year ago

opeolluwa commented 1 year ago

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

RPG-Alex commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

We can discuss it all here,

RPG-Alex commented 1 year ago

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

opeolluwa commented 1 year ago

Great!

opeolluwa commented 1 year ago

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

RPG-Alex commented 1 year ago

Got it. Thanks for letting me know.

opeolluwa commented 1 year ago

You are welcome 🤗

RPG-Alex commented 1 year ago

`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 commented 1 year ago

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 commented 1 year ago

See the solution pointed out here https://lockevn.medium.com/fix-typescript-error-ts5023-unknown-compiler-option-compileroptions-ca91dc655027

RPG-Alex commented 1 year ago

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 commented 1 year ago

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

opeolluwa commented 1 year ago

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

RPG-Alex commented 1 year ago

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 commented 1 year ago

I have yarn v 1.22.19.

Try deleting the browser directory, see if it works

opeolluwa commented 1 year ago

https://bobbyhadz.com/blog/typescript-import-path-cannot-end-with-ts-extension#:~:text=extension%20in%20TS-,The%20error%20%22An%20import%20path%20cannot%20end%20with%20a%20'.,extension%20from%20your%20TypeScript%20imports.

See this article on resolving error An import path cannot end with a '.ts' or '.tsx' extension

opeolluwa commented 1 year ago

Also, what version on Node.js do you use

opeolluwa commented 1 year ago

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 commented 1 year ago

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

RPG-Alex commented 1 year ago

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 commented 1 year ago

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

opeolluwa commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Hi, Alex, how is it going

RPG-Alex commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@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.