Add import/export settings buttons#9123
Conversation
You won't see a warning, it will purposefully silently drop them because they are not meant to be writeable by the window and you won't see any issues in the same window because in the same window you are showing the stuff in-memory in that window but it won't be saved to disk, synced to other windows or actually get used. While I don't want to discourage new contributors, could I please ask that you put a bit more thought into your pull requests or at the very least put more effort into testing them, as this is the second one that you have submitted that doesn't actually work in practice. |
|
You're right, I'm sorry. I'm a bit too eager to contribute. I did test my changes, but I saw your warning about the folder fields a bit late, and I only tested the settings value after import rather than actually testing whether the folders were correct. |
Pull request was converted to draft
|
Maybe folder paths should not be allowed to be imported, does it really make sense? It is user and OS dependent, in most case the imported path would be invalid. |
|
What probably should not be transferred:
|
|
I checked all the settings, I think that settings impacted by env like Concerning passwords, they are not encrypted, so exporting them as plain text would not be an issue. As for whether this is relevant, I’d tend to say yes, but it could be changed if needed. There are also settings that need the app to be restarted. I've made the implementation similar to the list of non-exportable settings for the declaration, and when they are imported, the user is prompted to restart the app or to revert the settings that needed a restart. It works but I will see if I find something more "elegant" |
|
I'm now satisfied with the state of this MR! |
Head branch was pushed to by a user without write access
…dependent of process.env
Head branch was pushed to by a user without write access
| return | ||
| } | ||
|
|
||
| if (process.env.IS_ELECTRON) { |
There was a problem hiding this comment.
Does this mean the prompt is shown for web build (even though not officially supported) and will do nothing?
There was a problem hiding this comment.
I've asked myself the same question, but I've used the same template as everywhere else
https://github.com/FreeTubeApp/FreeTube/blob/development/src/renderer/components/ThemeSettings.vue#L317
https://github.com/FreeTubeApp/FreeTube/blob/development/src/renderer/components/ExperimentalSettings/ExperimentalSettings.vue#L68
There was a problem hiding this comment.
@Shadorc The difference is that in the other places it will never even get to that code, the electron check is just there to ensure that the electron only code gets removed properly during the build (as deadcode removal isn't guaranteed with Vue in the mix) and makes it clearer to people reading the code that it is electron only.
E.g. for the smooth scrolling switch is not shown outside of electron: https://github.com/FreeTubeApp/FreeTube/blob/development/src/renderer/components/ThemeSettings.vue#L20 and the entire experimental settings component is Electron only: https://github.com/FreeTubeApp/FreeTube/blob/development/src/renderer/views/Settings/Settings.vue#L174-L181
So you can either make the entire settings import and export feature electron only or write it in a way that also has a non-Electron restart and flexible enough that an Android specific restart could be added in downstream FreeTubeAndroid.
There was a problem hiding this comment.
Thanks for the clarification.
I had searched for settings depending on the IS_ELECTRON env var, but I missed disableSmoothScrolling and hideToTrayOnMinimize.
Concerning your suggestions, I see one more option.
Instead of making the entire feature electron-only, all electron-only settings could be marked as not transferrable.
It would not remove a lot of settings because, according to my searches, here are the settings depending on process.env:
/* Depends on process.env.IS_ELECTRON */
// ProxySettings
'useProxy',
'proxyProtocol',
'proxyHostname',
'proxyPort',
'proxyUsername',
'proxyPassword',
// ExternalPlayerSettings
'externalPlayer',
'externalPlayerExecutable',
'externalPlayerIgnoreWarnings',
'externalPlayerIgnoreDefaultArgs',
'externalPlayerCustomArgs',
'showAddedExternalPlayerCustomArgs',
// Others
'disableSmoothScrolling',
'hideToTrayOnMinimize',
'screenshotAskPath',
'screenshotFolderPath',
/* Depends on process.env.SUPPORTS_LOCAL_API */
'backendFallback',
'backendPreference',
'proxyVideos',
If we remove settings mentioned here, we get:
/* Depends on process.env.IS_ELECTRON */
// Others
'disableSmoothScrolling',
'hideToTrayOnMinimize',
/* Depends on process.env.SUPPORTS_LOCAL_API */
'backendFallback',
'backendPreference',
'proxyVideos',
The last three depend on process.env.SUPPORTS_LOCAL_API, they should probably not be transferrable.
hideToTrayOnMinimize is OS-specific because it is not available on macOS.
The remaining one is disableSmoothScrolling.
So, making the whole feature electron-only would only be useful to support the smooth scrolling feature but would prevent users from importing and exporting settings on mobile.
It could still be possible to later implement your idea of having a flexible way to restart the app, no matter if it's electron or not, and add the missing support for disableSmoothScrolling.
I will update my MR to change the settingsNotExportable with all the settings mentioned above.
Let me know what you think, I've tried to imagine the best scenario for users, code maintainability and complexity.
Head branch was pushed to by a user without write access
Head branch was pushed to by a user without write access
Pull request was converted to draft
Head branch was pushed to by a user without write access
Head branch was pushed to by a user without write access
Pull Request Type
Related issue
#1018 (comment)
#7345
Description
This pull request adds support for importing and exporting FreeTube settings.
Some settings are not exportable, they are represented by the
settingsNotTransferrableset insidesettings.js. They are OS/user-specific settings, experimental settings, and settings that depend onprocess.env.I'm not entirely satisfied with having to duplicate setting keys, but the other solution that I thought of was to replace the state object values with a more complex structure, having additional fields like
isExportable. However, in my opinion, it would have required too much refactoring.Screenshots
Testing
Basic test
Non-exportable setting test
UI test