-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: develop
Are you sure you want to change the base?
Conversation
is Either.Success -> { | ||
user = userResponse.data | ||
emit( | ||
book(user = user!!, creatingBookModel = creatingBookModel) |
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.
давай уберем форсированный not null через let
val bookings = api | ||
.getBookingsByUser( | ||
userId = userResponse.data.id, | ||
beginDate = localDateTimeToUnix(beginDate)!!, |
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.
давай избегать форсированного not null
beginDate = localDateTimeToUnix(beginDate)!!, | ||
endDate = localDateTimeToUnix(endDate)!! | ||
) | ||
.convert( |
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.
не нравится вот эта функция. Не понятно во что она конвертит.
вообще код усложнен кучей параметров как будто.
// TODO add implemetation for error | ||
} | ||
is Either.Error -> { | ||
// TODO add implemetation for error |
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.
может добавим какую-нибудь ошибку )?
@@ -47,6 +50,10 @@ class ProfileRepositoryImpl( | |||
) | |||
) | |||
|
|||
init { | |||
updateUserFlow.tryEmit(Unit) |
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.
это для чего?
) | ||
) | ||
override suspend fun refresh(): Either<ErrorWithData<User>, User> { | ||
val cashedUser = bdSource.getCurrentUserInfo() |
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.
можно не исправлять, но как будто можно функцию refresh еще на несколько.
}
emit(dateForEmit) | ||
) | ||
} else { | ||
val requestResult = api.getUser(cashedUser.id).convert(lastResponse.value) |
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.
название переменной можно улучшить, слишком абстрактно.
Функция convert не дает понимания во что конвертится, давай явно укажим тип переменной
} | ||
|
||
bdSource.getCurrentUserInfo().packageEither(requestResult) |
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.
.packageEither - давай придумаем название получше
error = user.error.error, | ||
saveData = user.error.saveData?.formatToUI() | ||
) | ||
fun execute() = flow { |
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.
эта функция точно нужна в паблик? может сделаем private?
|
||
fun executeInFormat() = execute().map { user -> | ||
when (user) { | ||
is Either.Success -> Either.Success(user.data.formatToUI()) |
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.
нарушено разделение слоев, usecase - это домаин уровень и должен возвращать domain - модель
} | ||
} | ||
|
||
private fun User.formatToUI() = |
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.
User маппится в UI , но при этом модельки называются одинаково либо это одна и та же моделька. Давай исправим
@@ -67,6 +67,7 @@ internal class ProfileStoreFactory( | |||
|
|||
private fun fetchUserInfo() { | |||
scope.launch(Dispatchers.IO) { | |||
getUserUseCase |
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.
кажется это лишнее)
No description provided.