Added ability to upgrade to pro from the tray#8452
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes the system tray menu subscription-aware by adding an “Upgrade to Pro” entry for non‑Pro users and refreshing the tray menu when the user’s Pro status changes.
Changes:
- Added
_isUserProstate toSystemTrayNotifierand wired it toisUserProProviderwith a listener that triggers tray menu refresh. - Updated the tray menu to conditionally include an “Upgrade to Pro” action that opens the app window and navigates to the Plans screen.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| MenuItem.separator(), | ||
| if (!_isUserPro) | ||
| MenuItem( | ||
| key: 'upgrade_to_pro', | ||
| label: 'upgrade_to_pro'.i18n, | ||
| onClick: (_) { | ||
| ref.read(windowProvider.notifier).open(focus: true); | ||
| appRouter.push(Plans()); | ||
| }, | ||
| ), | ||
| MenuItem.separator(), | ||
| MenuItem( |
There was a problem hiding this comment.
When _isUserPro is true, the if (!_isUserPro) MenuItem(...) is skipped but the following MenuItem.separator() is still added, resulting in two consecutive separators in the tray menu (the separator at line 77 and the one at line 87). Make the separator conditional (or restructure the items list) so separators only appear between actual menu items.
| ref.listen<bool>( | ||
| isUserProProvider, | ||
| (previous, next) async { | ||
| _isUserPro = next; | ||
| await updateTrayMenu(); | ||
| }, |
There was a problem hiding this comment.
ref.listen callbacks are declared async and await updateTrayMenu(), but Riverpod does not await the returned Future. This can lead to overlapping updateTrayMenu() executions (from both the VPN status listener and this Pro-status listener) and out-of-order menu state if an earlier update completes after a later one. Consider making the listener callback synchronous and serializing/coalescing tray updates inside the notifier (e.g., via a queued update or a single in-flight refresh).
This pull request enhances the system tray menu by introducing dynamic behavior based on the user's subscription status. The main improvement is the addition of an "Upgrade to Pro" menu item for non-Pro users, and the notifier now listens for changes in the user's Pro status to update the tray menu accordingly.
User subscription awareness and tray menu updates:
_isUserProfield toSystemTrayNotifierand initialized it using theisUserProProvider. The notifier now listens for changes to the user's Pro status and updates the tray menu when it changes. [1] [2]