Skip to content

Commit 6c020a9

Browse files
committed
perf(content_management): prevent redundant source data fetching
- Add a check to avoid refetching sources if they are already loaded - This optimization prevents unnecessary API calls when switching tabs
1 parent 69f73d3 commit 6c020a9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/content_management/bloc/content_management_bloc.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ class ContentManagementBloc
263263
LoadSourcesRequested event,
264264
Emitter<ContentManagementState> emit,
265265
) async {
266+
// If sources are already loaded and it's not a pagination request,
267+
// do not re-fetch. This prevents redundant API calls on tab changes.
268+
if (state.sourcesStatus == ContentManagementStatus.success &&
269+
state.sources.isNotEmpty &&
270+
event.startAfterId == null) {
271+
return;
272+
}
273+
266274
emit(state.copyWith(sourcesStatus: ContentManagementStatus.loading));
267275
try {
268276
final isPaginating = event.startAfterId != null;

0 commit comments

Comments
 (0)