@@ -4,6 +4,8 @@ import 'package:data_table_2/data_table_2.dart';
44import 'package:flutter/material.dart' ;
55import 'package:flutter_bloc/flutter_bloc.dart' ;
66import 'package:flutter_news_app_web_dashboard_full_source_code/content_management/bloc/archived_sources/archived_sources_bloc.dart' ;
7+ import 'package:flutter_news_app_web_dashboard_full_source_code/content_management/bloc/content_management_bloc.dart' ;
8+ import 'package:flutter_news_app_web_dashboard_full_source_code/dashboard/bloc/dashboard_bloc.dart' ;
79import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/app_localizations.dart' ;
810import 'package:flutter_news_app_web_dashboard_full_source_code/l10n/l10n.dart' ;
911import 'package:intl/intl.dart' ;
@@ -35,10 +37,21 @@ class _ArchivedSourcesView extends StatelessWidget {
3537 ),
3638 body: Padding (
3739 padding: const EdgeInsets .all (AppSpacing .lg),
38- child: BlocBuilder <ArchivedSourcesBloc , ArchivedSourcesState >(
39- builder: (context, state) {
40- if (state.status == ArchivedSourcesStatus .loading &&
41- state.sources.isEmpty) {
40+ child: BlocListener <ArchivedSourcesBloc , ArchivedSourcesState >(
41+ listenWhen: (previous, current) =>
42+ previous.restoredSource != current.restoredSource,
43+ listener: (context, state) {
44+ if (state.restoredSource != null ) {
45+ context.read <ContentManagementBloc >().add (
46+ const LoadSourcesRequested (limit: kDefaultRowsPerPage),
47+ );
48+ context.read <DashboardBloc >().add (DashboardSummaryLoaded ());
49+ }
50+ },
51+ child: BlocBuilder <ArchivedSourcesBloc , ArchivedSourcesState >(
52+ builder: (context, state) {
53+ if (state.status == ArchivedSourcesStatus .loading &&
54+ state.sources.isEmpty) {
4255 return LoadingStateWidget (
4356 icon: Icons .source,
4457 headline: l10n.loadingArchivedSources,
@@ -116,7 +129,8 @@ class _ArchivedSourcesView extends StatelessWidget {
116129 ),
117130 ],
118131 );
119- },
132+ },
133+ ),
120134 ),
121135 ),
122136 );
0 commit comments