From 19bbdebdf7468a443899cc70ea06593f2e53318e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Wed, 16 Aug 2023 05:12:49 +0300 Subject: [PATCH] fix(mobile): Do not show version announcement if user is not admin. (#3703) --- mobile/lib/shared/providers/admin_provider.dart | 7 +++++++ mobile/lib/shared/views/version_announcement_overlay.dart | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 mobile/lib/shared/providers/admin_provider.dart diff --git a/mobile/lib/shared/providers/admin_provider.dart b/mobile/lib/shared/providers/admin_provider.dart new file mode 100644 index 0000000000..fc1126a92c --- /dev/null +++ b/mobile/lib/shared/providers/admin_provider.dart @@ -0,0 +1,7 @@ +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:immich_mobile/shared/providers/user.provider.dart'; + +final isAdminProvider = Provider((ref) { + final currentUser = ref.watch(currentUserProvider); + return currentUser?.isAdmin ?? false; // Default to non-admin if no user +}); diff --git a/mobile/lib/shared/views/version_announcement_overlay.dart b/mobile/lib/shared/views/version_announcement_overlay.dart index 8ec0d0b1bc..7cb8213fc8 100644 --- a/mobile/lib/shared/views/version_announcement_overlay.dart +++ b/mobile/lib/shared/views/version_announcement_overlay.dart @@ -3,6 +3,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/shared/providers/release_info.provider.dart'; +import 'package:immich_mobile/shared/providers/admin_provider.dart'; import 'package:url_launcher/url_launcher.dart'; class VersionAnnouncementOverlay extends HookConsumerWidget { @@ -12,6 +13,12 @@ class VersionAnnouncementOverlay extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + final bool isAdmin = ref.watch(isAdminProvider); + + if (!isAdmin) { + return const SizedBox.shrink(); // Don't show anything for non-admins + } + void goToReleaseNote() async { final Uri url = Uri.parse('https://github.com/immich-app/immich/releases/latest');