-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Refactor] Remover dependência do Modular ChatMainTalksPage
#395
base: main
Are you sure you want to change the base?
[Refactor] Remover dependência do Modular ChatMainTalksPage
#395
Conversation
… into 366-substituir-modularstate-por-state-em-chatmaintalkspage
Quality Gate passedIssues Measures |
Code Climate has analyzed commit 60d1946 and detected 0 issues on this pull request. View more on Code Climate. |
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.
Necessita algumas correções
chatMainPeopleController: ChatMainPeopleController( | ||
skillRepository: Modular.get<IFilterSkillRepository>(), | ||
usersRepository: Modular.get<IUsersRepository>()), | ||
controller: ChatMainController( | ||
chatToggleFeature: ChatPrivateToggleFeature( | ||
modulesServices: Modular.get<IAppModulesServices>())), | ||
chatMainTalksController: ChatMainTalksController( | ||
chatChannelRepository: Modular.get<IChatChannelRepository>()), |
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.
Para melhorar a lógica, é melhor manter a criação do controllers no Bind (onde já estão) e aqui consumir a injeção, melhorando a organização e a manutenibilidade do código.
chatMainPeopleController: ChatMainPeopleController( | |
skillRepository: Modular.get<IFilterSkillRepository>(), | |
usersRepository: Modular.get<IUsersRepository>()), | |
controller: ChatMainController( | |
chatToggleFeature: ChatPrivateToggleFeature( | |
modulesServices: Modular.get<IAppModulesServices>())), | |
chatMainTalksController: ChatMainTalksController( | |
chatChannelRepository: Modular.get<IChatChannelRepository>()), | |
chatMainPeopleController: Modular.get<ChatMainPeopleController>(), | |
controller: Modular.get<ChatMainController>(), | |
chatMainTalksController: Modular.get<ChatMainTalksController>(), |
@override | ||
void initState() { | ||
super.initState(); | ||
controller.initialize(); |
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.
Melhor garantir que o controller seja acionado apenas quando as Widgets estiverem prontas para isto
controller.initialize(); | |
WidgetsBinding.instance.addPostFrameCallback((_) { | |
controller.initialize(); | |
}); |
controller: SupportCenterController( | ||
supportCenterUseCase: SupportCenterUseCase( | ||
locationService: Modular.get<ILocationServices>(), | ||
supportCenterRepository: SupportCenterRepository( | ||
apiProvider: Modular.get<ApiProvider>()))), |
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.
Não entendi a necessidade de alterar este código, não entendi a relação desta alteração com o PR
Proposta de Pull Request: Refatoração do ChatMainTalksPage para incluir IChatMainTalksController como dependência
Resumo
Este pull request faz alterações na implementação de ChatMainPage e ChatMainTalksPage para utilizar a injeção de dependência de um
IChatMainTalksController
. Isso melhora a testabilidade e desacopla ainda mais o código.Alterações principais
Refatoração de
ChatMainPage
:iChatMainTalksController
.controller
para oChatMainTalksPage
.Modificação em
ChatMainTalksPage
:controller
como uma dependência obrigatória.ModularState
.Atualização de testes:
MockIChatMainTalksController
para substituir dependências reais nos testes.ChatMainTalksState.error
eChatMainTalksState.loaded
.Arquivos modificados
lib/app/features/chat/presentation/chat_main_module.dart
Alterado para passar o
IChatMainTalksController
na criação daChatMainPage
.lib/app/features/chat/presentation/chat_main_page.dart
Adicionado o parâmetro obrigatório
iChatMainTalksController
naChatMainPage
.lib/app/features/chat/presentation/talk/chat_main_talks_page.dart
Alterado para aceitar um
IChatMainTalksController
explicitamente na construção da página.test/app/features/chat/presentation/talk/chat_main_talks_page_test.dart
Adicionadas as configurações de teste para o novo design.
Goldens atualizados:
test/app/features/chat/presentation/talk/goldens/ci/chat_main_talks_page_error_state.png
test/app/features/chat/presentation/talk/goldens/ci/chat_main_talks_page_initial_state.png
Diferença de código (Git Diff)