Skip to content

Commit 4a7651f

Browse files
committed
refactor(account): update imports and rename exception types
- Update imports to use core and data_repository packages - Rename HtAuthRepository to AuthRepository - Rename HtDataRepository to DataRepository - Replace HtHttpException with HttpException - Remove unused imports - Update class and variable names to use new repository interfaces
1 parent 4f4eae9 commit 4a7651f

File tree

4 files changed

+34
-35
lines changed

4 files changed

+34
-35
lines changed

lib/account/bloc/account_bloc.dart

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import 'dart:async';
22

3+
import 'package:auth_repository/auth_repository.dart';
34
import 'package:bloc/bloc.dart';
5+
import 'package:core/core.dart';
6+
import 'package:data_repository/data_repository.dart';
47
import 'package:equatable/equatable.dart';
5-
import 'package:ht_auth_repository/ht_auth_repository.dart';
6-
import 'package:ht_data_repository/ht_data_repository.dart';
7-
import 'package:ht_main/app/config/config.dart' as local_config;
8-
import 'package:ht_shared/ht_shared.dart';
8+
import 'package:flutter_news_app_mobile_client_full_source_code/app/config/config.dart'
9+
as local_config;
910
import 'package:logging/logging.dart';
1011

1112
part 'account_event.dart';
1213
part 'account_state.dart';
1314

1415
class AccountBloc extends Bloc<AccountEvent, AccountState> {
1516
AccountBloc({
16-
required HtAuthRepository authenticationRepository,
17-
required HtDataRepository<UserContentPreferences>
17+
required AuthRepository authenticationRepository,
18+
required DataRepository<UserContentPreferences>
1819
userContentPreferencesRepository,
1920
required local_config.AppEnvironment environment,
2021
Logger? logger,
@@ -23,7 +24,7 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
2324
_environment = environment,
2425
_logger = logger ?? Logger('AccountBloc'),
2526
super(const AccountState()) {
26-
// Listen to user changes from HtAuthRepository
27+
// Listen to user changes from AuthRepository
2728
_userSubscription = _authenticationRepository.authStateChanges.listen((
2829
user,
2930
) {
@@ -39,8 +40,8 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
3940
on<AccountClearUserPreferences>(_onAccountClearUserPreferences);
4041
}
4142

42-
final HtAuthRepository _authenticationRepository;
43-
final HtDataRepository<UserContentPreferences>
43+
final AuthRepository _authenticationRepository;
44+
final DataRepository<UserContentPreferences>
4445
_userContentPreferencesRepository;
4546
final local_config.AppEnvironment _environment;
4647
final Logger _logger;
@@ -149,9 +150,9 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
149150
clearError: true,
150151
),
151152
);
152-
} on HtHttpException catch (e) {
153+
} on HttpException catch (e) {
153154
_logger.severe(
154-
'Failed to create default preferences with HtHttpException: $e',
155+
'Failed to create default preferences with HttpException: $e',
155156
);
156157
emit(state.copyWith(status: AccountStatus.failure, error: e));
157158
} catch (e, st) {
@@ -169,9 +170,9 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
169170
),
170171
);
171172
}
172-
} on HtHttpException catch (e) {
173+
} on HttpException catch (e) {
173174
_logger.severe(
174-
'AccountLoadUserPreferences failed with HtHttpException: $e',
175+
'AccountLoadUserPreferences failed with HttpException: $e',
175176
);
176177
emit(state.copyWith(status: AccountStatus.failure, error: e));
177178
} catch (e, st) {
@@ -227,9 +228,9 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
227228
clearError: true,
228229
),
229230
);
230-
} on HtHttpException catch (e) {
231+
} on HttpException catch (e) {
231232
_logger.severe(
232-
'AccountSaveHeadlineToggled failed with HtHttpException: $e',
233+
'AccountSaveHeadlineToggled failed with HttpException: $e',
233234
);
234235
emit(state.copyWith(status: AccountStatus.failure, error: e));
235236
} catch (e, st) {
@@ -284,10 +285,8 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
284285
clearError: true,
285286
),
286287
);
287-
} on HtHttpException catch (e) {
288-
_logger.severe(
289-
'AccountFollowTopicToggled failed with HtHttpException: $e',
290-
);
288+
} on HttpException catch (e) {
289+
_logger.severe('AccountFollowTopicToggled failed with HttpException: $e');
291290
emit(state.copyWith(status: AccountStatus.failure, error: e));
292291
} catch (e, st) {
293292
_logger.severe(
@@ -344,9 +343,9 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
344343
clearError: true,
345344
),
346345
);
347-
} on HtHttpException catch (e) {
346+
} on HttpException catch (e) {
348347
_logger.severe(
349-
'AccountFollowSourceToggled failed with HtHttpException: $e',
348+
'AccountFollowSourceToggled failed with HttpException: $e',
350349
);
351350
emit(state.copyWith(status: AccountStatus.failure, error: e));
352351
} catch (e, st) {
@@ -392,9 +391,9 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
392391
clearError: true,
393392
),
394393
);
395-
} on HtHttpException catch (e) {
394+
} on HttpException catch (e) {
396395
_logger.severe(
397-
'AccountClearUserPreferences failed with HtHttpException: $e',
396+
'AccountClearUserPreferences failed with HttpException: $e',
398397
);
399398
emit(state.copyWith(status: AccountStatus.failure, error: e));
400399
} catch (e, st) {

lib/account/bloc/account_state.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ class AccountState extends Equatable {
1313
final AccountStatus status;
1414
final User? user;
1515
final UserContentPreferences? preferences;
16-
final HtHttpException? error;
16+
final HttpException? error;
1717

1818
AccountState copyWith({
1919
AccountStatus? status,
2020
User? user,
2121
UserContentPreferences? preferences,
22-
HtHttpException? error,
22+
HttpException? error,
2323
bool clearUser = false,
2424
bool clearPreferences = false,
2525
bool clearError = false,

lib/account/bloc/available_sources_bloc.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import 'dart:async';
22

33
import 'package:bloc/bloc.dart';
4+
import 'package:core/core.dart' show HttpException, Source;
5+
import 'package:data_repository/data_repository.dart';
46
import 'package:equatable/equatable.dart';
5-
import 'package:ht_data_repository/ht_data_repository.dart';
6-
import 'package:ht_shared/ht_shared.dart' show HtHttpException, Source;
77

88
part 'available_sources_event.dart';
99
part 'available_sources_state.dart';
1010

1111
class AvailableSourcesBloc
1212
extends Bloc<AvailableSourcesEvent, AvailableSourcesState> {
13-
AvailableSourcesBloc({required HtDataRepository<Source> sourcesRepository})
13+
AvailableSourcesBloc({required DataRepository<Source> sourcesRepository})
1414
: _sourcesRepository = sourcesRepository,
1515
super(const AvailableSourcesState()) {
1616
on<FetchAvailableSources>(_onFetchAvailableSources);
1717
}
1818

19-
final HtDataRepository<Source> _sourcesRepository;
19+
final DataRepository<Source> _sourcesRepository;
2020
// Consider adding a limit if the number of sources can be very large.
2121
// static const _sourcesLimit = 50;
2222

@@ -46,7 +46,7 @@ class AvailableSourcesBloc
4646
clearError: true,
4747
),
4848
);
49-
} on HtHttpException catch (e) {
49+
} on HttpException catch (e) {
5050
emit(
5151
state.copyWith(
5252
status: AvailableSourcesStatus.failure,

lib/account/bloc/available_topics_bloc.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import 'dart:async';
22

33
import 'package:bloc/bloc.dart';
4+
import 'package:core/core.dart';
5+
import 'package:data_repository/data_repository.dart';
46
import 'package:equatable/equatable.dart';
5-
import 'package:ht_data_repository/ht_data_repository.dart';
6-
import 'package:ht_shared/ht_shared.dart';
77

88
part 'available_topics_event.dart';
99
part 'available_topics_state.dart';
1010

1111
class AvailableTopicsBloc
1212
extends Bloc<AvailableTopicsEvent, AvailableTopicsState> {
13-
AvailableTopicsBloc({required HtDataRepository<Topic> topicsRepository})
13+
AvailableTopicsBloc({required DataRepository<Topic> topicsRepository})
1414
: _topicsRepository = topicsRepository,
1515
super(const AvailableTopicsState()) {
1616
on<FetchAvailableTopics>(_onFetchAvailableTopics);
1717
}
1818

19-
final HtDataRepository<Topic> _topicsRepository;
19+
final DataRepository<Topic> _topicsRepository;
2020

2121
Future<void> _onFetchAvailableTopics(
2222
FetchAvailableTopics event,
@@ -36,7 +36,7 @@ class AvailableTopicsBloc
3636
clearError: true,
3737
),
3838
);
39-
} on HtHttpException catch (e) {
39+
} on HttpException catch (e) {
4040
emit(
4141
state.copyWith(status: AvailableTopicsStatus.failure, error: e.message),
4242
);

0 commit comments

Comments
 (0)