thermal
thermal copied to clipboard
Sync/update data between vuex and database
The current approach we're following in this chore/add-nodegit
branch is to update the database and then get the data from database and updating the whole repository
array of objects.
With small database size it can work pretty efficiently but as the data grows inside the database, it can be different to maintain the performance of the application.
There're some unique scenarios with similar concepts:
Initialise repository
To improve the performance of the application we’re relaying in vuex, when the app mount for the first-time, required data is fetched from the database and saved inside vuex store.
directoryPath: "./code/gitthermal/thermal"
isGit: 1
repositoryId: 0
repositoryName: thermal
These are five data properties stored inside repository vuex store.
If a user adds a non-git repository, database register the data as
isGit: 0
(means it is a non-git repository), and Thermal allows you to initialise git repository.
When the Init
button is clicked the repository is initialise and database is updated for the same but it still shows to Init the repository because vuex store is still unaware of the changes made to database.
In order to fix the above, I create a bug fix for the same, but it still boils down to same thing.
You can see the source code for app mounting on first load.
Repository settings
We're not storing all the information inside the repository vuex store, except the important or data which is required at multiple places.
In this settings page the data is fetched from data with life-cycle mounted hook and stored inside local settings
data property.
For updating/saving data back to database we're not storing the data inside vuex store instead directly hit the database by providing the required input data.
You can see the source code of repository/settings.vue
.
I would like to hear your thoughts on how we can further improve this.