Skip to content

Commit 7ef3cd7

Browse files
committed
refactor(auth, database): use language fixtures instead of hardcoding
- Replace hardcoded English language object with lookup in language fixtures - Throw error if default language not found in fixtures - Update both auth_service.dart and database_seeding_service.dart
1 parent 744ee0b commit 7ef3cd7

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

lib/src/services/auth_service.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,11 @@ class AuthService {
529529
textScaleFactor: AppTextScaleFactor.medium,
530530
fontWeight: AppFontWeight.regular,
531531
),
532-
language: Language(
533-
id: '6633b7ac1892f06e6914d0b3',
534-
code: 'en',
535-
name: 'English',
536-
nativeName: 'English',
537-
createdAt: DateTime.now(),
538-
updatedAt: DateTime.now(),
539-
status: ContentStatus.active,
532+
language: languagesFixturesData.firstWhere(
533+
(l) => l.code == 'en',
534+
orElse: () => throw StateError(
535+
'Default language "en" not found in language fixtures.',
536+
),
540537
),
541538
feedPreferences: const FeedDisplayPreferences(
542539
headlineDensity: HeadlineDensity.standard,

lib/src/services/database_seeding_service.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,12 @@ class DatabaseSeedingService {
258258
textScaleFactor: AppTextScaleFactor.medium,
259259
fontWeight: AppFontWeight.regular,
260260
),
261-
language: Language(
262-
id: '6633b7ac1892f06e6914d0b3',
263-
code: 'en',
264-
name: 'English',
265-
nativeName: 'English',
266-
createdAt: DateTime.now(),
267-
updatedAt: DateTime.now(),
268-
status: ContentStatus.active,
261+
language: languagesFixturesData.firstWhere(
262+
(l) => l.code == 'en',
263+
orElse: () => throw StateError(
264+
'Default language "en" not found in language fixtures.',
269265
),
266+
),
270267
feedPreferences: const FeedDisplayPreferences(
271268
headlineDensity: HeadlineDensity.standard,
272269
headlineImageStyle: HeadlineImageStyle.smallThumbnail,

0 commit comments

Comments
 (0)