-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Can't save language preference #314
Bug: Can't save language preference #314
Comments
I can confirm this on the native mac app v0.6.5 as well. |
Thanks @ceruleanjo and @Johennes! The root issue is that both the Mac and Windows apps pick a random port for each session, causing any saved LocalStorage items (including the language and theme preferences) to be reset. Ideally, we need a mechanism for each native app to save user preferences outside of the hosted web app, then restore them at launch. |
Oh, interesting. I think that would be a limitation for #310 as well then. 😔 I'm not proficient in the Windows side, unfortunately. But for the mac app, we could maybe retrieve the storage in applicationWillTerminate (which allows for around 5 seconds of processing) and store it into the native user defaults. Then on launch of the app, we could re-inject it into the web view similar to how it's done for the session token – only that of course we'd only want to run this once, not on every page load. I had a brief look at the event APIs for storage objects as well and they seem limited. |
Thanks @Johennes. Yes, ideally the native app would retrieve localStorage and store that in UserDefault, then push that back to the WebView on reload. The localStorage keys we need to persist are:
Ideally, there would be a JS/TS function that returns the properties to persist, and a corresponding one to apply them - so the list would live in the web code, called from the native app wrapper. P1 is calling this before terminate (though I have found the terminate event to be unreliable on macOS). If you would like to take a crack at any part of this, that would be great! We can follow the same pattern on the other OS clients later. Thanks! |
I took a stab at the pre-terminate-export in #331. There were a lot more moving pieces to it than I had anticipated though and I had to deviate from the original idea a little to get it to work. Would appreciate thoughts and feedback in the PR. |
Awesome, thanks so much @Johennes! I added some thoughts and comments in the PR. |
Continuing the conversation from the PR here @Willyfrog. I've merged PR #331 (thanks @Johennes!), which persists the localStorage settings as a blob on window close on macOS. There are a number of additional improvements we can make from here, including:
Keeping this issue open for further discussion and fixes. If anyone wants to work on this further, just mention it here. Thanks! |
I took a look into the webview API used in the Linux app:
One problem I hit when fooling around with the above is that the app seems to be killed when quitting it via the window manager button. I tried catching As for storing the exported settings, the most naive idea I had was to just put the base64 blob into a text file at |
yep, linux has a couple of ways of killing an app, so it might be tricky to look for all. when you mention the "window manager button" you mean the X in the title bar or killing it from another app?
I'd go with |
I meant the X button, yeah. Maybe it would make sense then to first follow through along the path you started in #333 and implement dynamic settings export upon settings change. That would free us from having to deal with any application life-cycle events. |
This switches from exporting the native app user settings on window close to exporting on settings change. This way the settings export remains independent of native application life-cycle events. This is a stop-gap towards enabling settings export on the native Linux app. The latter does not have an easy way to catch window close events. Relates to: mattermost-community#314
I pushed #380 to switch over to exporting the user settings dynamically on change. Apart from making the export in the mac app more reliable, this should make for a good basis to implement the export in the Linux (and possibly Windows) app as there's no more dependence on app life-cycle events anymore. |
* [GH-314] Export native app user settings on change This switches from exporting the native app user settings on window close to exporting on settings change. This way the settings export remains independent of native application life-cycle events. This is a stop-gap towards enabling settings export on the native Linux app. The latter does not have an easy way to catch window close events. Relates to: #314 * Disable no-shadow rule to prevent false-positive * Verify allowed localStorage keys * Fix import order/spacing * Treat JSON parsing errors as failed import * Read known keys from the correct type 🤦 * Extend logging with imported keys and always include _current_ user settings * Fixing eslint Co-authored-by: Hossein <[email protected]> Co-authored-by: Jesús Espino <[email protected]>
This commit adds persistence for the user settings in the native Linux app. The settings are written to $XDG_CONFIG_HOME/focalboard/settings. If XDG_CONFIG_HOME is unset, the app falls back to $HOME/.config. The change hooks into the existing settings export already used in the nativve macOS app which means the settings are persisted immediately on change. Unfortunately, the golang webview package uses a custom native binding technology and doesn't allow to define WebKit message handlers. As a result, a dedicated message handler function was added to the existing NativeApp object. In the native macOS app, said handler is short-circuited to window.webkit.messagehandlers.[NAME].postMessage. This has the benefit that the web app remains agnostic of the particular native binding mechanism. Relates to: mattermost-community#314
Update win-wpf app to persist user settings (issue mattermost-community#314)
Summary:
The app forgets my language choice every time I restart it.
Steps to reproduce the behavior:
Expected behavior:
The language preference should be persistent.
Screenshots:
If applicable, add screenshots to help explain your problem.
Platform:
Additional context:
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: