Simplify cvm assignment logic

Co-authored-by: Samantaz Fox <coding@samantaz.fr>
This commit is contained in:
ChunkyProgrammer 2024-04-20 10:04:27 -04:00 committed by GitHub
parent fbf07e18aa
commit 9d591a2214
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -133,11 +133,11 @@ module Invidious::Comments
node_replies = node["replies"]["commentRepliesRenderer"]
end
if node["commentViewModel"]?
if cvm = node["commentViewModel"]?
# two commentViewModels for inital request
cvm = node.dig?("commentViewModel", "commentViewModel")
# one commentViewModel when getting a replies to a comment
cvm ||= node.dig("commentViewModel")
cvm = cvm["commentViewModel"] if cvm["commentViewModel"]?
comment_key = cvm["commentKey"]
toolbar_key = cvm["toolbarStateKey"]
comment_mutation = mutations.find { |i| i.dig?("payload", "commentEntityPayload", "key") == comment_key }