Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lib/features/system_tray/provider/system_tray_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ part 'system_tray_notifier.g.dart';
@Riverpod(keepAlive: true)
class SystemTrayNotifier extends _$SystemTrayNotifier with TrayListener {
late VPNStatus _currentStatus;
bool _isUserPro = false;

@override
Future<void> build() async {
Expand All @@ -26,6 +27,15 @@ class SystemTrayNotifier extends _$SystemTrayNotifier with TrayListener {
},
);

_isUserPro = ref.read(isUserProProvider);
ref.listen<bool>(
isUserProProvider,
(previous, next) async {
_isUserPro = next;
await updateTrayMenu();
},
Comment on lines +31 to +36
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
);

ref.onDispose(() {
trayManager.removeListener(this);
});
Expand Down Expand Up @@ -65,6 +75,16 @@ class SystemTrayNotifier extends _$SystemTrayNotifier with TrayListener {
onClick: (_) => toggleVPN(),
),
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(
Comment on lines 77 to 88
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
key: 'join_server',
label: 'join_server'.i18n,
Expand Down
Loading