π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix locker loading state
AmanRajSinghMouryab0620d37b450
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dartindex a0a2c27fca..287ea66caa 100644--- a/mobile/apps/locker/lib/ui/pages/home_page.dart+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart@@ -183,9 +183,7 @@ class CustomLockerAppBar extends StatelessWidgetminHeight: 44,),),- style: TextStyle(- color: colorScheme.iconColor,- ),+ style: TextStyle(color: colorScheme.iconColor),),),),@@ -215,20 +213,31 @@ class _HomePageState extends UploaderPageState<HomePage>final _searchFocusNode = FocusNode();final _selectedFiles = SelectedFiles();final _scrollController = ScrollController();- bool _isLoading = true;- bool _hasLoadedFromDb = false;- bool _hasCompletedInitialLoad = false;+ bool _isLoadingLocalCache = true;+ bool _hasLoadedLocalCache = false;+ bool _hasCompletedInitialSync = false;bool _isSettingsOpen = false;- bool get _isLoadingFromDb => !_hasLoadedFromDb && _isLoading;- bool get _isSyncingWithServer =>- _hasLoadedFromDb && !_hasCompletedInitialLoad;+ bool get _isLoadingFromLocalCache =>+ !_hasLoadedLocalCache && _isLoadingLocalCache;+ bool get _isInitialSyncInProgress =>+ _hasLoadedLocalCache && !_hasCompletedInitialSync;+ bool get _hasAnyLocalContent =>+ _collections.isNotEmpty || _recentFiles.isNotEmpty;+ bool get _shouldShowCenterSyncLoader =>+ _isLoadingFromLocalCache ||+ (_isInitialSyncInProgress && !_hasAnyLocalContent);+ bool get _shouldShowAppBarSyncIndicator =>+ _isInitialSyncInProgress && _hasAnyLocalContent;+ bool get _canShowFinalEmptyState =>+ _hasLoadedLocalCache && _hasCompletedInitialSync;List<Collection> _collections = [];List<Collection> _filteredCollections = [];List<EnteFile> _recentFiles = [];List<EnteFile> _filteredFiles = [];- final ValueNotifier<List<EnteFile>> _displayedFilesNotifier =- ValueNotifier([]);+ final ValueNotifier<List<EnteFile>> _displayedFilesNotifier = ValueNotifier(+ [],+ );String? _error;final _logger = Logger('HomePage');@@ -316,8 +325,9 @@ class _HomePageState extends UploaderPageState<HomePage>await _loadCollections();});- _triggerLogoutSubscription =- Bus.instance.on<TriggerLogoutEvent>().listen((event) async {+ _triggerLogoutSubscription = Bus.instance.on<TriggerLogoutEvent>().listen((+ event,+ ) async {await _autoLogoutAlert();});}@@ -353,10 +363,7 @@ class _HomePageState extends UploaderPageState<HomePage>text: context.l10n.ok,onTap: () async {navigator.pop();- final dialog = createProgressDialog(- context,- l10n.pleaseWait,- );+ final dialog = createProgressDialog(context, l10n.pleaseWait);await dialog.show();await Configuration.instance.logout();await dialog.hide();@@ -375,8 +382,9 @@ class _HomePageState extends UploaderPageState<HomePage>_mediaStreamSubscription =ReceiveSharingIntent.instance.getMediaStream().listen((List<SharedMediaFile> value) {- _logger- .info('Received shared media files via stream: ${value.length}');+ _logger.info(+ 'Received shared media files via stream: ${value.length}',+ );for (var file in value) {_logger.info('Shared file received, type: ${file.type}');}@@ -406,8 +414,9 @@ class _HomePageState extends UploaderPageState<HomePage>_logger.info('Initial media check result: ${initialMedia.length} files');if (initialMedia.isNotEmpty) {- _logger- .info('Found initial shared media files: ${initialMedia.length}');+ _logger.info(+ 'Found initial shared media files: ${initialMedia.length}',+ );for (var file in initialMedia) {_logger.info('Initial shared file, type: ${file.type}');}@@ -487,14 +496,14 @@ class _HomePageState extends UploaderPageState<HomePage>}Future<void> _loadCollections() async {- final shouldShowLoading =- _collections.isEmpty && _recentFiles.isEmpty && !_isLoading;+ final shouldTriggerTransientLoadingState =+ _collections.isEmpty && _recentFiles.isEmpty && !_isLoadingLocalCache;try {- if (mounted && (shouldShowLoading || _error != null)) {+ if (mounted && (shouldTriggerTransientLoadingState || _error != null)) {setState(() {- if (shouldShowLoading) {- _isLoading = true;+ if (shouldTriggerTransientLoadingState) {+ _isLoadingLocalCache = true;}_error = null;});@@ -517,27 +526,30 @@ class _HomePageState extends UploaderPageState<HomePage>await _loadRecentFiles(collections);}- final sortedCollections =- CollectionSortUtil.getSortedCollections(collections);+ final sortedCollections = CollectionSortUtil.getSortedCollections(+ collections,+ );if (mounted) {setState(() {_collections = sortedCollections;_filteredCollections = _filterOutUncategorized(sortedCollections);_filteredFiles = _recentFiles;- _isLoading = false;- _hasLoadedFromDb = true;- _hasCompletedInitialLoad = hasCompletedFirstSync;+ _isLoadingLocalCache = false;+ _hasLoadedLocalCache = true;+ _hasCompletedInitialSync = hasCompletedFirstSync;});}} catch (error) {+ _logger.severe('Error fetching collections', error);if (mounted) {+ final hasCompletedFirstSync =+ CollectionService.instance.hasCompletedFirstSync();setState(() {_error = 'Error fetching collections: $error';- _isLoading = false;- _hasLoadedFromDb = true;- _hasCompletedInitialLoad =- CollectionService.instance.hasCompletedFirstSync();+ _isLoadingLocalCache = false;+ _hasLoadedLocalCache = true;+ _hasCompletedInitialSync = hasCompletedFirstSync;});}}@@ -648,7 +660,7 @@ class _HomePageState extends UploaderPageState<HomePage>appBar: CustomLockerAppBar(scaffoldKey: scaffoldKey,isSearchActive: isSearchActive,- isSyncing: _isSyncingWithServer,+ isSyncing: _shouldShowAppBarSyncIndicator,searchController: searchController,searchFocusNode: _searchFocusNode,onSearchFocused: _handleSearchFocused,@@ -701,16 +713,6 @@ class _HomePageState extends UploaderPageState<HomePage>}Widget _buildBody() {- if (_isLoadingFromDb) {- final colorScheme = getEnteColorScheme(context);- return Center(- child: CircularProgressIndicator(- strokeWidth: 3,- color: colorScheme.primary700,- ),- );- }-if (_error != null) {return Center(child: Padding(@@ -725,16 +727,23 @@ class _HomePageState extends UploaderPageState<HomePage>showBorder: false,),const SizedBox(height: 20),- GradientButton(- onTap: _loadCollections,- text: context.l10n.retry,- ),+ GradientButton(onTap: _loadCollections, text: context.l10n.retry),],),),);}+ if (_shouldShowCenterSyncLoader) {+ final colorScheme = getEnteColorScheme(context);+ return Center(+ child: CircularProgressIndicator(+ strokeWidth: 3,+ color: colorScheme.primary700,+ ),+ );+ }+if (isSearchActive) {return SingleChildScrollView(physics: const AlwaysScrollableScrollPhysics(),@@ -748,6 +757,9 @@ class _HomePageState extends UploaderPageState<HomePage>);}if (_displayedCollections.isEmpty) {+ if (!_canShowFinalEmptyState) {+ return const SizedBox.shrink();+ }return const Center(child: Padding(padding: EdgeInsets.all(16.0),@@ -761,12 +773,14 @@ class _HomePageState extends UploaderPageState<HomePage>final scrollBottomPadding = MediaQuery.of(context).padding.bottom + 120;return _recentFiles.isEmpty- ? const Center(- child: Padding(- padding: EdgeInsets.symmetric(horizontal: 16.0),- child: HomeEmptyStateWidget(),- ),- )+ ? !_canShowFinalEmptyState+ ? const SizedBox.shrink()+ : const Center(+ child: Padding(+ padding: EdgeInsets.symmetric(horizontal: 16.0),+ child: HomeEmptyStateWidget(),+ ),+ ): SingleChildScrollView(controller: _scrollController,physics: const AlwaysScrollableScrollPhysics(),@@ -793,9 +807,6 @@ class _HomePageState extends UploaderPageState<HomePage>}void _openSavePage() {- showSaveBottomSheet(- context,- onUploadDocument: addFile,- );+ showSaveBottomSheet(context, onUploadDocument: addFile);}}