-
Notifications
You must be signed in to change notification settings - Fork 27
refactor feature fetch message structure #1528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
lib/features/message/presentation/bloc/message_animation/message_animation_cubit.dart
Show resolved
Hide resolved
lib/features/message/presentation/bloc/base_message/base_message_bloc.dart
Outdated
Show resolved
Hide resolved
lib/features/message/presentation/bloc/base_message/base_message_bloc.dart
Outdated
Show resolved
Hide resolved
lib/features/message/data/repository_impl/message_repository_impl.dart
Outdated
Show resolved
Hide resolved
lib/features/message/data/datasource_impl/remote_message_datasource_impl.dart
Outdated
Show resolved
Hide resolved
lib/features/message/data/repository_impl/message_repository_impl.dart
Outdated
Show resolved
Hide resolved
|
|
||
| part 'base_message_event.dart'; | ||
|
|
||
| part 'base_message_state.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is recommended to use absolute path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thanks for the work, now everything is done on сubits and I don't see the point in adding new blocks with events, it's better to keep everything on сubits IMHO
| final threadId = event.threadId ?? Globals.instance.threadId; | ||
|
|
||
| List<Message> lastList = const []; | ||
| await for (var list in stream) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, Should be split into smaller functions
|
|
||
| emit(MessagesLoadSuccess( | ||
| messages: list, | ||
| hash: list.fold(0, (acc, m) => acc + m.hash), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, Create function to generate hash key
| }); | ||
|
|
||
| @override | ||
| List<Object?> get props => []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, properties should be added to props for future comparison.
| Duration(milliseconds: 50), | ||
| FocusManager.instance.primaryFocus?.unfocus, | ||
| ); | ||
| Get.find<MessageAnimationCubit>().endAnimation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is recommended to use Get.find centralized in one place
dab246
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick review:
- Objects should be
immutable - Fill in
propertiesinprops - Should create
instanceofGet.findand use it. Avoid writing: `Get.find().function() - Should create separate function for events in call from
onTap,onClick - Note
convension code:- There are too many parameters of the function, each parameter should be
1 line. - Indentation should be
1 tab
- There are too many parameters of the function, each parameter should be
EvGen94
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
§
|
|
||
| part 'base_message_event.dart'; | ||
|
|
||
| part 'base_message_state.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thanks for the work, now everything is done on сubits and I don't see the point in adding new blocks with events, it's better to keep everything on сubits IMHO
Hi! Reason to change some cubit to bloc:
|
9c6fb44 to
1abcb50
Compare
1abcb50 to
47a445e
Compare
| import 'package:twake/core/state/success.dart'; | ||
|
|
||
| @immutable | ||
| abstract class AppState with EquatableMixin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need this class?
| this._messageRepository, | ||
| ); | ||
|
|
||
| Either<ExceptionFailure, Stream<List<Message>>> execute({ String? companyId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@
| import 'package:flutter/material.dart'; | ||
| import 'package:twake/models/globals/globals.dart'; | ||
|
|
||
| abstract class RepositoryHelper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain your idea?
| if (!Globals.instance.isNetworkConnected) { | ||
| onLocal?.call(); | ||
| return; | ||
| } | ||
| onRemote?.call(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it is not generic enough. For example: when we need to first: fetch data from local, in parallel, fetch the data with network to update.
|
|
||
| if (event.threadId == null) emit(MessagesLoadInProgress()); | ||
|
|
||
| final result = _fetchMessageUseCase.execute( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, we need an method to execute all the usecase
No description provided.