Skip to content

EO-746: refactor data saving on ProfileScreen #321

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 1 commit into
base: develop
Choose a base branch
from

Conversation

Qiraa
Copy link
Contributor

@Qiraa Qiraa commented Apr 11, 2025

No description provided.

@Qiraa Qiraa requested a review from gull192 April 11, 2025 05:57
is Either.Success -> {
user = userResponse.data
emit(
book(user = user!!, creatingBookModel = creatingBookModel)
Copy link
Collaborator

Choose a reason for hiding this comment

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

давай уберем форсированный not null через let

val bookings = api
.getBookingsByUser(
userId = userResponse.data.id,
beginDate = localDateTimeToUnix(beginDate)!!,
Copy link
Collaborator

Choose a reason for hiding this comment

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

давай избегать форсированного not null

beginDate = localDateTimeToUnix(beginDate)!!,
endDate = localDateTimeToUnix(endDate)!!
)
.convert(
Copy link
Collaborator

Choose a reason for hiding this comment

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

не нравится вот эта функция. Не понятно во что она конвертит.

вообще код усложнен кучей параметров как будто.

// TODO add implemetation for error
}
is Either.Error -> {
// TODO add implemetation for error
Copy link
Collaborator

Choose a reason for hiding this comment

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

может добавим какую-нибудь ошибку )?

@@ -47,6 +50,10 @@ class ProfileRepositoryImpl(
)
)

init {
updateUserFlow.tryEmit(Unit)
Copy link
Collaborator

Choose a reason for hiding this comment

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

это для чего?

)
)
override suspend fun refresh(): Either<ErrorWithData<User>, User> {
val cashedUser = bdSource.getCurrentUserInfo()
Copy link
Collaborator

Choose a reason for hiding this comment

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

можно не исправлять, но как будто можно функцию refresh еще на несколько.

}

emit(dateForEmit)
)
} else {
val requestResult = api.getUser(cashedUser.id).convert(lastResponse.value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

название переменной можно улучшить, слишком абстрактно.
Функция convert не дает понимания во что конвертится, давай явно укажим тип переменной

}

bdSource.getCurrentUserInfo().packageEither(requestResult)
Copy link
Collaborator

Choose a reason for hiding this comment

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

.packageEither - давай придумаем название получше

error = user.error.error,
saveData = user.error.saveData?.formatToUI()
)
fun execute() = flow {
Copy link
Collaborator

Choose a reason for hiding this comment

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

эта функция точно нужна в паблик? может сделаем private?


fun executeInFormat() = execute().map { user ->
when (user) {
is Either.Success -> Either.Success(user.data.formatToUI())
Copy link
Collaborator

Choose a reason for hiding this comment

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

нарушено разделение слоев, usecase - это домаин уровень и должен возвращать domain - модель

}
}

private fun User.formatToUI() =
Copy link
Collaborator

Choose a reason for hiding this comment

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

User маппится в UI , но при этом модельки называются одинаково либо это одна и та же моделька. Давай исправим

@@ -67,6 +67,7 @@ internal class ProfileStoreFactory(

private fun fetchUserInfo() {
scope.launch(Dispatchers.IO) {
getUserUseCase
Copy link
Collaborator

Choose a reason for hiding this comment

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

кажется это лишнее)

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