-
Notifications
You must be signed in to change notification settings - Fork 114
Add user preference to open emails in new window #4259
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
base: master
Are you sure you want to change the base?
Add user preference to open emails in new window #4259
Conversation
Adds a new user preference setting that allows users to configure emails to open in a new browser tab by default instead of inline preview. When enabled on web platform, clicking an email will automatically open it in a new browser tab. Changes: - Add OpenEmailInNewWindowConfig preference model - Integrate with PreferencesSettingManager for persistence - Add preferences toggle in settings UI via PreferencesOptionType - Load preference at dashboard startup via extension - Use preference in ThreadController email preview action Co-Authored-By: Claude Opus 4.5 <[email protected]>
WalkthroughThis pull request introduces a new "Open emails in new window" feature that allows users to configure whether clicking on emails opens them in a new browser tab instead of the current view. The implementation includes a new configuration model, integration into the preferences system, updates to the mailbox dashboard controller to load and expose the configuration state, localization strings for UI labels, and conditional logic in the thread controller to route email preview actions to the new tab opening flow when the feature is enabled on web. Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart`:
- Around line 140-141: The controller currently reads
isOpenEmailInNewWindowEnabled only in onReady (in MailboxDashboardController),
so changes in Settings won’t apply until restart; update the controller to
refresh preferences after returning from the Settings flow (or subscribe to
local settings changes) by invoking the same preference-loading logic used in
onReady — e.g., add a public method like reloadPreferences()/loadSettings() that
re-reads the preference flags (isOpenEmailInNewWindowEnabled and any
reopenComposerCache flag from reopen_composer_cache_extension), call that method
after the Settings navigation completes (or wire it to the settings change
stream) and ensure any UI/state consumers are updated accordingly.
🧹 Nitpick comments (1)
lib/features/mailbox_dashboard/presentation/extensions/open_email_in_new_window_extension.dart (1)
7-18: Narrow the try/catch aroundgetBindingusage; null checks don't throw exceptions.
getBinding<T>()returns null rather than throwing when a binding is not found. The current broad try/catch wraps the entire method unnecessarily and masks errors from the actual async operation. Move the null check outside and only guard the async call.♻️ Suggested refactor
- Future<void> loadOpenEmailInNewWindowConfig() async { - try { - final preferencesManager = getBinding<PreferencesSettingManager>(); - if (preferencesManager != null) { - final config = await preferencesManager.getOpenEmailInNewWindowConfig(); - isOpenEmailInNewWindowEnabled.value = config.isEnabled; - log('OpenEmailInNewWindowExtension::loadOpenEmailInNewWindowConfig: isEnabled = ${config.isEnabled}'); - } - } catch (e) { - log('OpenEmailInNewWindowExtension::loadOpenEmailInNewWindowConfig: error = $e'); - isOpenEmailInNewWindowEnabled.value = false; - } - } + Future<void> loadOpenEmailInNewWindowConfig() async { + final preferencesManager = getBinding<PreferencesSettingManager>(); + if (preferencesManager == null) { + log('OpenEmailInNewWindowExtension::loadOpenEmailInNewWindowConfig: PreferencesSettingManager not registered'); + isOpenEmailInNewWindowEnabled.value = false; + return; + } + try { + final config = await preferencesManager.getOpenEmailInNewWindowConfig(); + isOpenEmailInNewWindowEnabled.value = config.isEnabled; + log('OpenEmailInNewWindowExtension::loadOpenEmailInNewWindowConfig: isEnabled = ${config.isEnabled}'); + } catch (e) { + log('OpenEmailInNewWindowExtension::loadOpenEmailInNewWindowConfig: error = $e'); + isOpenEmailInNewWindowEnabled.value = false; + } + }
lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart
Show resolved
Hide resolved
- Add unit tests for OpenEmailInNewWindowConfig model (14 tests) - Constructor defaults, JSON serialization/deserialization - copyWith extension, equality comparison - Add persistence tests for PreferencesSettingManager (7 tests) - get/update methods, round-trip verification - loadPreferences integration Co-Authored-By: Claude Opus 4.5 <[email protected]>
The feature only works on web (uses browser tabs), so hiding the toggle on mobile and desktop prevents user confusion. Co-Authored-By: Claude Opus 4.5 <[email protected]>
The preference was only loaded in onReady(), so changes made in Settings wouldn't apply until app restart. Now loadOpenEmailInNewWindowConfig() is called after both goToSettings() and goToVacationSetting() return, matching the pattern used for loadAIScribeConfig(). Co-Authored-By: Claude Opus 4.5 <[email protected]>
| } else if (PlatformInfo.isWeb && mailboxDashBoardController.isOpenEmailInNewWindowEnabled.value) { | ||
| openEmailInNewTabAction(selectedEmail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This function only supports opening emails in a new tab, not a new window. If you want to open them in a new window, please rewrite the function.
tddang-linagora
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Generate and commit updated arb
- Stop the infinite email opening
Summary
Changes
OpenEmailInNewWindowConfig- Preference model with JSON serializationOpenEmailInNewWindowExtension- Dashboard extension to load preference at startupPreferencesSettingManager- Added persistence methods for new configPreferencesSetting- Added getter for new configPreferencesOptionType- Added enum value with UI text methodsPreferencesController- Added toggle handler for the settingMailboxDashBoardController- Added reactive variable, load call, and reload after SettingsPreferencesView- Added platform check to hide toggle on non-web platformsThreadController- Checks preference on email preview actionAppLocalizations- Added localization stringsTests (21 tests)
Test plan
🤖 Generated with Claude Code