-
Notifications
You must be signed in to change notification settings - Fork 0
Day 1 inf #5
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: day-1
Are you sure you want to change the base?
Day 1 inf #5
Conversation
palkan
left a comment
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.
Есть пару моментов, которые надо исправить, а в целом всё верно.
app/views/tracks/index.html.erb
Outdated
| <% tracks.each_with_index do |track, i| %> | ||
| <%= render track, track_counter: page * page_size + i, enqueueble: true %> | ||
| <% end %> |
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.
Правильную нумерацию можно (и нужно) сделать через рендеринг коллекции; нужно просто задать стартовую позицию. Откатываться на each — плохая идея (это менее производительно).
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.
Поправила, правда я думала, что можно сделать через track_counter, но пришлось добавить новую локал переменную
app/views/tracks/_load_page.html.erb
Outdated
| @@ -0,0 +1 @@ | |||
| <%= turbo_frame_tag "tracks_page_#{page}", src: artist_tracks_path(artist, page: page), loading: "lazy" %> | |||
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.
Получается, что на каждую страницу мы рендеринг не только список треков, но и шапку (просто она не используем самим Турбо); получается лишняя и бесполезная работа для сервера. Нужно бы сделать так, чтобы возвращался только список треков (и следующий фрейм, если нужно).
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.
Поправила
Задание:
Необходимо добавить новую страницу со всеми треками артиста с ленивой подгрузкой треков при прокрутке (aka infinite scroll pagination). Использовать только Turbo Frames.