Closed thombruce closed 3 months ago
This is currently working a treat for just colorMode, and what I have here so far is extendible. It also serves as the basis for...
App data!
For example, Toodles can read and write its todos from/to a file.
But... before we do that, this is going to get kind of messy if we keep doubling and doubling up on this approach.
We could separate some of the IPC handling out of the electron/main.ts
file (and we probably will for cleanliness and clarity), but better still...
I think the next step is to install and make use of Pinia. Our Pinia store(s) can then hold and handle the mutation of values, and it can select an appropriate storage mechanism based on its environment...
All of that is out of the scope of this PR, and config settings... simple config settings I am presently content to handle with the current approach. So following review, this could be ready to merge as is unless there are any last minute changes to be made.
That said, you know there is a strong argument to be made for moving configuration state into its own composable...
In its own composable, it could manage its own state and mutations (basic ones) and I could separate out some of this if (isElectron)
stuff from the visible components.
I might do this here and see how it looks, see how it feels.
Create maybe a useTntConfig
composable for that, which also wraps useColorMode
?
An attempt was made to add a useTntConfig()
composable which updates useColorMode()
and the Electron config document, but...
useColorMode()
does not seem to be accessible outside of our components. There's a related discussion on the Pinia repo: https://github.com/vuejs/pinia/discussions/762
Things are simple enough right now that I'm happy pressing forward as is. But we might revisit this idea eventually... for instance, we could create a store property for our config which color-mode is watching - when the store config updates, we would then update the useColorMode().preference
in our components. This kind of makes more sense, as useColorMode (despite also exposing configuration) is a presentation concern; we would update this presentation concern when our own advanced-store configuration is changed.
But that, I leave to the future. We'll ignore the issue for now... I think... I mean... Actually, I might quickly try something...
Edit: No, no. What I'm trying to "quickly" try is still proving complicated and may be a bad pattern. We will leave the functionality as is for now, and see if we find an opportunity to tackle that concept when we have a clearer configuration option in the future.
Adds reading and setting configuration from a file when running an app in Electron container.
By submitting this pull request, you agree to follow our Code of Conduct: https://github.com/thombruce/.github/blob/main/CODE_OF_CONDUCT.md
Internal use. Do not delete.