Prevent saving a sort opt unnecessarily

This commit is contained in:
Leeingnyo
2021-08-30 08:19:15 +09:00
parent 51a47b5ddd
commit 00c9cc1fcd
4 changed files with 24 additions and 13 deletions

View File

@@ -107,6 +107,26 @@ macro get_sort_opt
end
end
macro get_and_save_sort_opt(dir)
sort_method = env.params.query["sort"]?
if sort_method
is_ascending = true
ascend = env.params.query["ascend"]?
if ascend && ascend.to_i? == 0
is_ascending = false
end
sort_opt = SortOptions.new sort_method, is_ascending
TitleInfo.new {{dir}} do |info|
info.sort_by[username] = sort_opt.to_tuple
info.save
end
end
end
module HTTP
class Client
private def self.exec(uri : URI, tls : TLSContext = nil)