mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-25 15:07:22 +00:00
Fix watch history order (#3653)
This commit is contained in:
commit
1eb1bae370
@ -52,7 +52,7 @@ module Invidious::Database::Users
|
|||||||
def mark_watched(user : User, vid : String)
|
def mark_watched(user : User, vid : String)
|
||||||
request = <<-SQL
|
request = <<-SQL
|
||||||
UPDATE users
|
UPDATE users
|
||||||
SET watched = array_append(watched, $1)
|
SET watched = array_append(array_remove(watched, $1), $1)
|
||||||
WHERE email = $2
|
WHERE email = $2
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ module Invidious::Routes::Watch
|
|||||||
end
|
end
|
||||||
env.params.query.delete_all("iv_load_policy")
|
env.params.query.delete_all("iv_load_policy")
|
||||||
|
|
||||||
if watched && preferences.watch_history && !watched.includes? id
|
if watched && preferences.watch_history
|
||||||
Invidious::Database::Users.mark_watched(user.as(User), id)
|
Invidious::Database::Users.mark_watched(user.as(User), id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -259,9 +259,7 @@ module Invidious::Routes::Watch
|
|||||||
|
|
||||||
case action
|
case action
|
||||||
when "action_mark_watched"
|
when "action_mark_watched"
|
||||||
if !user.watched.includes? id
|
|
||||||
Invidious::Database::Users.mark_watched(user, id)
|
Invidious::Database::Users.mark_watched(user, id)
|
||||||
end
|
|
||||||
when "action_mark_unwatched"
|
when "action_mark_unwatched"
|
||||||
Invidious::Database::Users.mark_unwatched(user, id)
|
Invidious::Database::Users.mark_unwatched(user, id)
|
||||||
else
|
else
|
||||||
|
@ -48,7 +48,7 @@ struct Invidious::User
|
|||||||
|
|
||||||
if data["watch_history"]?
|
if data["watch_history"]?
|
||||||
user.watched += data["watch_history"].as_a.map(&.as_s)
|
user.watched += data["watch_history"].as_a.map(&.as_s)
|
||||||
user.watched.uniq!
|
user.watched.reverse!.uniq!.reverse!
|
||||||
Invidious::Database::Users.update_watch_history(user)
|
Invidious::Database::Users.update_watch_history(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user