Skip to content

Conversation

@kvld
Copy link
Contributor

@kvld kvld commented Nov 14, 2017

Задача: #APPS-1648

Коротко для Release Notes, в формате «Сделали/Добавили/Исправили N»:
Исправили проблему, когда не открывался степ по диплинку

Описание:
Для степа, который открывался по диплинку, подгружался только урок, поэтому ничего не знали о состоянии enrollment (если он не был закеширован заранее). Из-за этого нельзя было открыть степ по диплинку, если до этого ни разу не открывался сам курс в приложении.
Теперь честно подгружаем каждый раз состояние курса (не уверен, что нужно смотреть на данные в кор дате, т. к. они могут быть устаревшими).

@kvld kvld added this to the 1.47 milestone Nov 14, 2017
@kvld kvld self-assigned this Nov 14, 2017
@kvld kvld requested a review from Ostrenkiy November 14, 2017 15:46
Copy link
Contributor

@Ostrenkiy Ostrenkiy left a comment

Choose a reason for hiding this comment

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

Пока, кажется, плохо будет работать, не мерджим

// let navigation : UINavigationController = StyledNavigationViewController(rootViewController: stepsVC)
// navigation.navigationBar.topItem?.leftBarButtonItem = UIBarButtonItem(image: Images.crossBarButtonItemImage, style: UIBarButtonItemStyle.Plain, target: self, action: #selector(StepsControllerDeepLinkRouter.dismissPressed(_:)))
// navigation.navigationBar.topItem?.leftBarButtonItem?.tintColor = UIColor.whiteColor()
fileprivate func getVCForLesson(_ lesson: Lesson, stepId: Int, success successHandler: @escaping ((UIViewController) -> Void), error errorHandler: @escaping ((String) -> Void)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

КАКОЙ ЖЕ ЭТО
АД
ААА
МНЕ БОЛЬНО
хз как это тестить
надеюсь работает

Copy link
Contributor

Choose a reason for hiding this comment

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

Смотрю на эту елочку
Хочу включить "Last christmas I gave you my heart" и плакать

Copy link
Contributor

Choose a reason for hiding this comment

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

Вообще, это плохо работает. Потому что надо доставать из кор даты нужные нам юниты, секции и курсы и пихать их в existing: параметр для retrieve, чтобы они обновлялись (да, это отстойный легаси). И на каждом шаге надо присваивать юниту - урок, секции - юнит, курсу - секцию

@Ostrenkiy
Copy link
Contributor

Сюда надо бы подмерджить dev и порешать конфликты в кор дате

@kvld
Copy link
Contributor Author

kvld commented Nov 30, 2017

@Ostrenkiy посмотри. Переписал этот кусок с промисами и отдельными обёртками fetchOrLoad (можно подумать над тем, чтобы вынести их в апи слой для всех сущностей).

Copy link
Contributor

@Ostrenkiy Ostrenkiy left a comment

Choose a reason for hiding this comment

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

Надо поправить

return
fileprivate func getVCForLesson(_ lesson: Lesson, stepId: Int, success successHandler: @escaping ((UIViewController) -> Void), error errorHandler: @escaping ((String) -> Void)) {
func fetchOrLoadUnit(lesson: Lesson) -> Promise<Unit> {
return Promise { resolve, reject in
Copy link
Contributor

Choose a reason for hiding this comment

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

а есть какой-то сакральный смысл у resolve вместо fulfill в названии?

}

ApiDataDownloader.units.retrieve(lesson: lesson.id, success: { unit in
resolve(unit)
Copy link
Contributor

Choose a reason for hiding this comment

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

тут, кажется, надо unit.lesson = lesson сделать

successHandler(lessonVC)
} else {
errorHandler("No access")
func fetchOrLoadSection(_ id: Int) -> Promise<Section> {
Copy link
Contributor

Choose a reason for hiding this comment

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

сюда, кажется, лучше передавать unit, чтобы потом unit.section = section сделать

}
}

func fetchOrLoadCourse(_ id: Int) -> Promise<Course> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Аналогично и здесь, надо section.course = course делать

@kvld
Copy link
Contributor Author

kvld commented Dec 1, 2017

@Ostrenkiy померджил с dev, можно и нужно смотреть.

resolve(course)
func fetchOrLoadCourse(for section: Section) -> Promise<Course> {
return Promise { fulfill, reject in
if let course = Course.getCourses([section.courseId]).first {
Copy link
Contributor

Choose a reason for hiding this comment

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

Вот здесь courseId запросто может быть -1, если мы его не успели перезаписать после миграции. Будет крашиться.

@Ostrenkiy Ostrenkiy modified the milestones: 1.47, 1.49 Dec 11, 2017
@kvld
Copy link
Contributor Author

kvld commented Dec 13, 2017

@Ostrenkiy тоже можно смотреть в очередной раз.

@Ostrenkiy
Copy link
Contributor

завтра посмотрю уже

@Ostrenkiy
Copy link
Contributor

теперь все хорошо вроде, надо только конфликты порешать

@Ostrenkiy Ostrenkiy merged commit b71bd5a into dev Dec 15, 2017
@Ostrenkiy Ostrenkiy deleted the fix/step-deeplinking branch December 15, 2017 11:12
@Ostrenkiy Ostrenkiy mentioned this pull request Dec 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants