Skip to content

Feature/Show groups list #45

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

HenriqueDelgad0
Copy link
Contributor

The problem

We need to show the created groups in groupTabScreen

The solution

Just listing all groups from user, without details for now. This task implements the list and updates in case of a new group was added.

Captura de Tela 2022-10-20 às 10 53 03

Copy link
Member

@pablobaldez pablobaldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cara, muito bom o PR.
Me surpeendi com a tua evolução. Acho que tu entendeu bem a ideia do asyncState e do projeto num geral.
Deixei alguns comentários aí, vamos falando sobre eles caso tu tenha alguma dúvida. Deixa que eu marco as conversas como resolved conforme vc for fazendo as alterações

if (user.authType == Anonymous) {
throw NotAuthorizedForItException()
}
// if (user.authType == Anonymous) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pode deletar o código

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foi


//Faz sentido essa Exception que eu criei?
class GetGroupsListException(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

faz sim. se essa request pro firebase falhar em produção vai ser bem fácil ver ela no crashlytics.
A única coisa que vc nao precisava enviar é o userId no logo, pq eu fiz uma magia pra sempre colocar o userId em todas as exceptions que logamos.

@@ -66,16 +66,21 @@ sealed class AppRouteDestination(val route: String) {
@Composable
fun HomeNavGraph(homeUiState: HomeUiState, subscription: Subscription) {

val groupsViewModel = getStateViewModel<GroupTabViewModel> {
parametersOf()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pq esse parametersOf vazio?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Não sei também, vou remover ele aqui

override fun fromUi(uiEvent: GroupsUIEvent) {
) : StateViewModel<CreateGroupData, CreateGroupUIEvent>(CreateGroupData(), loading = false) {

override fun fromUi(uiEvent: CreateGroupUIEvent) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pequeno detalhe: em kotlin se usa camel case por convenção, mesmo para abreviações. Então preferencialmente vc pode trocar o UI por Ui nessa classe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feito

Comment on lines 25 to 26
private val repository: GroupRepository,
private val userRepository: UserRepository
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lá vem textão:
na medida em que as regras de negócio na tela de grupo forem crescendo, talvez mais repositórios sejam necessários.
não é uma boa implementar regras de negócio no ViewModel, pq ele é uma classe que serve pra outras finalidades, como gerenciar o estado da UI.

Portanto, talvez seja melhor criar uma class UseCase, tipo GetGroupsUseCase, e fazer com que esse usecase use os repositórios pra implementar as regras de negócio.
A vantagem disso é que tiramos as regras de negócio de uma classe que interage com uma biblioteca externa, que é caso do ViewModel.

é um detalhe besta em um primeiro momento, mas essas pequenas decisões tem um peso grande conforme o projeto vai crescendo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pode crer, faz sentido. Como essa tela não ia ter useCase por enquanto acabei fazendo tudo no viewModel mesmo, mas vou me atentar mais nisso nas próximas.

Comment on lines 128 to 130
InfoTemplate(
icon = { Icon(imageVector = Icons.Default.Person, contentDescription = "groups tab") },
title = { Text("Sem grupos") },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eu acho uma boa já colocar esses textos nos strings resources, porque assim evitamos que por algum vacilo a gente esqueça de remover um deles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foi

getGroups()
}

fun getGroups() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tem algum motivo pra essa função ser pública?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sim, ele é usado no GroupTabScreen, pra quando eu adicionar um novo grupo a tela ja mostrar a lista atualizada, ai chama essa função de novo.

@@ -61,9 +62,20 @@ class GroupCollection(
batch.commit().awaitWithTimeout()
}

suspend fun getGroupsByUserId(founder: User) : List<GroupEntry> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alerta de dica irrelevante:
como esse já é o GroupCollection, acho que da pra tirar o Groups do nome desse método, assim evita duplicação de palavras

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foi

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants