Skip to content

Commit

Permalink
fix(mobile): Do not show version announcement if user is not admin. (i…
Browse files Browse the repository at this point in the history
  • Loading branch information
samip5 authored Aug 16, 2023
1 parent bc66b1a commit 19bbdeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mobile/lib/shared/providers/admin_provider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/shared/providers/user.provider.dart';

final isAdminProvider = Provider<bool>((ref) {
final currentUser = ref.watch(currentUserProvider);
return currentUser?.isAdmin ?? false; // Default to non-admin if no user
});
7 changes: 7 additions & 0 deletions mobile/lib/shared/views/version_announcement_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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');
Expand Down

0 comments on commit 19bbdeb

Please sign in to comment.