Skip to content

Commit f135ef3

Browse files
committed
refactor(shared): define constant for in-feed decorator position
- Introduce a static constant `_decoratorInsertionIndex` with a value of 3 - Move the constant definition from the `insertDecorator` method to the class level - Update the method to use the new class-level constant
1 parent c6ab2ae commit f135ef3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/shared/services/feed_decorator_service.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class FeedDecoratorService {
6767
final DataRepository<Topic> _topicsRepository;
6868
final DataRepository<Source> _sourcesRepository;
6969

70+
// The zero-based index in the feed where the decorator will be inserted.
71+
// A value of 3 places it after the third headline, which is a common
72+
// position for in-feed promotional content.
73+
static const _decoratorInsertionIndex = 3;
74+
7075
// Defines the static priority for each feed decorator. A lower number is a
7176
// higher priority. This list determines which decorator is chosen when
7277
// multiple decorators are "due" at the same time.
@@ -125,9 +130,8 @@ class FeedDecoratorService {
125130
if (injectedDecorator != null) {
126131
// Inject the decorator at a fixed, predictable position.
127132
// We use `min` to handle cases where the headline list is very short.
128-
const decoratorInsertionIndex = 3;
129133
final safeIndex = min(
130-
decoratorInsertionIndex,
134+
_decoratorInsertionIndex,
131135
feedWithDecorators.length,
132136
);
133137
feedWithDecorators.insert(safeIndex, injectedDecorator);

0 commit comments

Comments
 (0)