whyboris / Video-Hub-App

Official repository for Video Hub App
https://videohubapp.com
MIT License
591 stars 179 forks source link

Remember preferred number of screenshots and size in wizard #504

Closed whyboris closed 2 years ago

whyboris commented 4 years ago

It's very likely users who create many hubs have preferred settings. We may as well remember those.

Remember in the Wizard:

23mwest commented 4 years ago

First timer here, can I try to tackle this?

whyboris commented 4 years ago

Hey @23mwest 👋 awesome 😁 Please feel free to reach out with any questions about anything. I'm happy to give hints or more-detailed suggestions (whichever you'd like) 🤝

23mwest commented 4 years ago

Awesome - appreciate it!

23mwest commented 4 years ago

Hey @whyboris 👋 Wondering if you have anything set up already to persist data between runs of the app (Didn't see anything in the dependencies). Found electron-json-storage and electron-store as two answers here Lmk if you like one over the other or if I'm missing something you already have in the app. Thanks!

orkomlosh commented 4 years ago

Hey, the persist data of the app is saved in settings.json, one of the interface that's being saved there can be found here: src\app\common\app-state.ts settings object is this: interfaces\settings-object.interface.ts

and the place that write/read it in: main.ts

whyboris commented 4 years ago

Thank you @orkomlosh 🙇 @23mwest -- feel free to ask for clarification / more help. Especially that I'm working with TypeScript which you might not be instantly familiar with (even if you're good with JavaScript) 👍

A quickstart: main.ts is stuff that runs in Node and communicates through "IPC" with Angular, here is when the settings return: https://github.com/whyboris/Video-Hub-App/blob/main/src/app/components/home.component.ts#L677 🚀

23mwest commented 4 years ago

@orkomlosh @whyboris Thank you both for your replies, it is a bit confusing and it's not even my first time with TypeScript. 😅 I think I'm starting to understand what's going on though. Looks like this code is the setter for the object? event.sender.send('settings-returning', previouslySavedSettings, locale);

whyboris commented 4 years ago

the event.sender.send('something', data) is the way for node to communicate to Angular through: Electron Docs

The 'something' is the message name -- as long as Angular is listening for that message, it can run arbitrary code upon receipt of the data that's sent 🤝

This specific line sends over the "previously saved settings" (saved JSON as a JS object) to Angular. Angular then listens for it thus:

this.electronService.ipcRenderer.on('settings-returning', (
      event,
      settingsObject: SettingsObject,
      locale: string
    ) => {

in home.component 😁

23mwest commented 4 years ago

Finally got somewhere with this thanks to you guys, but I'm running into an issue with bindings that seems to stump me every time I use Angular... I get the settings and set it to the WizardOptions in home.component like this: if (settingsObject.wizardSettings) { this.wizard = settingsObject.wizardSettings; } but when the wizard loads it still has the default value of 10. I tried the "banana-in-the-box" two-way binding in both home.component.html and wizard.component.html, and just about every other possible combination of bindings I could think of. Any Ideas? Edit: Disregard this, sorry. I don't think it has to do with the bindings.

whyboris commented 4 years ago

👋 this stuff is a bit tricky 👌 The html dictates what is selected as default upon load, for example, notice the selected option for screenshot size: https://github.com/whyboris/Video-Hub-App/blob/main/src/app/components/wizard/wizard.component.html#L247 The number input has a default set as well: https://github.com/whyboris/Video-Hub-App/blob/main/src/app/components/wizard/wizard.component.html#L179 👍

whyboris commented 4 years ago

@23mwest let me know if you still would like a hand with this 👍

23mwest commented 2 years ago

@whyboris Sorry I took so long on this... I was a bit rusty at the time and things were not clicking whatsoever for me. Finally got around to going back and opened a PR: https://github.com/whyboris/Video-Hub-App/pull/736

whyboris commented 2 years ago

Hey @23mwest - no worries at all! I've been busy with house stuff for almost a year -- finally getting around to VHA in the coming months; this is great timing.

Cheers!

whyboris commented 2 years ago

🙇 thank you @23mwest for the excellent PR 🎉 I merged it #736 -- thank you for improving VHA 🥇