feat(user): improve user data handling with async provider

This commit is contained in:
cogwheel0
2025-11-27 21:41:32 +05:30
parent de18f1463c
commit 0c140580f5
3 changed files with 19 additions and 3 deletions

View File

@@ -1478,7 +1478,12 @@ class _ChatsDrawerState extends ConsumerState<ChatsDrawer> {
Widget _buildBottomSection(BuildContext context) {
final theme = context.conduitTheme;
final sidebarTheme = context.sidebarTheme;
final user = ref.watch(currentUserProvider2);
final authUser = ref.watch(currentUserProvider2);
final asyncUser = ref.watch(currentUserProvider);
final user = asyncUser.maybeWhen(
data: (value) => value ?? authUser,
orElse: () => authUser,
);
final api = ref.watch(apiServiceProvider);
String initialFor(String name) {

View File

@@ -5,6 +5,7 @@ import 'package:flutter_animate/flutter_animate.dart';
import 'package:conduit/l10n/app_localizations.dart';
import '../../auth/providers/unified_auth_providers.dart';
import '../../../core/providers/app_providers.dart';
import '../../../core/utils/user_display_name.dart';
import '../../../shared/theme/theme_extensions.dart';
import '../../../shared/widgets/sheet_handle.dart';
@@ -67,7 +68,12 @@ class _OnboardingSheetState extends ConsumerState<OnboardingSheet> {
Widget build(BuildContext context) {
final height = MediaQuery.of(context).size.height;
final l10n = AppLocalizations.of(context)!;
final user = ref.watch(currentUserProvider2);
final authUser = ref.watch(currentUserProvider2);
final asyncUser = ref.watch(currentUserProvider);
final user = asyncUser.maybeWhen(
data: (value) => value ?? authUser,
orElse: () => authUser,
);
final greetingName = deriveUserDisplayName(user);
final pages = _buildPages(l10n, greetingName);
final pageCount = pages.length;

View File

@@ -41,7 +41,12 @@ class ProfilePage extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final user = ref.watch(currentUserProvider2);
final authUser = ref.watch(currentUserProvider2);
final asyncUser = ref.watch(currentUserProvider);
final user = asyncUser.maybeWhen(
data: (value) => value ?? authUser,
orElse: () => authUser,
);
final isAuthLoading = ref.watch(isAuthLoadingProvider2);
final api = ref.watch(apiServiceProvider);