Use sorted_titles

This commit is contained in:
Leeingnyo 2021-12-26 00:27:00 +09:00
parent 234b29bbdd
commit 8fea35fa51
3 changed files with 12 additions and 2 deletions

View File

@ -252,6 +252,10 @@ class Title
@title_ids.map { |tid| Library.default.get_title! tid }
end
def sorted_titles(username, opt : SortOptions? = nil)
titles
end
# Get all entries, including entries in nested titles
def deep_entries
return @entries if title_ids.empty?

View File

@ -61,9 +61,15 @@ struct MainRouter
sort_opt = SortOptions.from_info_json title.dir, username
get_and_save_sort_opt title.dir
sorted_titles = title.sorted_titles username, sort_opt
entries = title.sorted_entries username, sort_opt
percentage = title.load_percentage_for_all_entries username, sort_opt
title_percentage = title.titles.map &.load_percentage username
title_percentage_map = {} of String => Float64
title_percentage.each_with_index do |percentage, i|
t = title.titles[i]
title_percentage_map[t.id] = percentage
end
layout "title"
rescue e

View File

@ -60,8 +60,8 @@
</div>
<div class="uk-child-width-1-4@m uk-child-width-1-2" uk-grid>
<% title.titles.each_with_index do |item, i| %>
<% progress = title_percentage[i] %>
<% sorted_titles.each do |item| %>
<% progress = title_percentage_map[item.id] %>
<%= render_component "card" %>
<% end %>
</div>