Skip to content

Commit 8a745ac

Browse files
committed
refactor(content_management): add comments explaining background fetching process
- Add detailed comments in both create_source_bloc.dart and edit_source_bloc.dart - Explain the reason for using background fetching for countries and languages - Highlight UI consistency and technical limitations as motivations - Describe how the UI updates progressively in the background
1 parent 08e7b8b commit 8a745ac

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

lib/content_management/bloc/create_source/create_source_bloc.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,17 @@ class CreateSourceBloc extends Bloc<CreateSourceEvent, CreateSourceState> {
6666
),
6767
);
6868

69-
// Start background fetching for all countries
69+
// After the initial page is loaded, start a background process to
70+
// fetch all remaining pages for countries and languages.
71+
//
72+
// This approach is used for the following reasons:
73+
// 1. UI Consistency: It allows us to use the standard
74+
// `DropdownButtonFormField`, which is used elsewhere in the app.
75+
// 2. Technical Limitation: The standard dropdown does not expose a
76+
// scroll controller, making on-scroll pagination impossible.
77+
//
78+
// The UI will update progressively and silently in the background as
79+
// more data arrives.
7080
while (state.countriesHasMore) {
7181
final nextCountries = await _countriesRepository.readAll(
7282
pagination: PaginationOptions(cursor: state.countriesCursor),
@@ -81,7 +91,6 @@ class CreateSourceBloc extends Bloc<CreateSourceEvent, CreateSourceState> {
8191
);
8292
}
8393

84-
// Start background fetching for all languages
8594
while (state.languagesHasMore) {
8695
final nextLanguages = await _languagesRepository.readAll(
8796
pagination: PaginationOptions(cursor: state.languagesCursor),

lib/content_management/bloc/edit_source/edit_source_bloc.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,17 @@ class EditSourceBloc extends Bloc<EditSourceEvent, EditSourceState> {
9090
),
9191
);
9292

93-
// Start background fetching for all countries
93+
// After the initial page is loaded, start a background process to
94+
// fetch all remaining pages for countries and languages.
95+
//
96+
// This approach is used for the following reasons:
97+
// 1. UI Consistency: It allows us to use the standard
98+
// `DropdownButtonFormField`, which is used elsewhere in the app.
99+
// 2. Technical Limitation: The standard dropdown does not expose a
100+
// scroll controller, making on-scroll pagination impossible.
101+
//
102+
// The UI will update progressively and silently in the background as
103+
// more data arrives.
94104
while (state.countriesHasMore) {
95105
final nextCountries = await _countriesRepository.readAll(
96106
pagination: PaginationOptions(cursor: state.countriesCursor),
@@ -105,7 +115,6 @@ class EditSourceBloc extends Bloc<EditSourceEvent, EditSourceState> {
105115
);
106116
}
107117

108-
// Start background fetching for all languages
109118
while (state.languagesHasMore) {
110119
final nextLanguages = await _languagesRepository.readAll(
111120
pagination: PaginationOptions(cursor: state.languagesCursor),

0 commit comments

Comments
 (0)