From 3ccd8021b7fdc6028a9eb6db1f265572759dca26 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 28 May 2021 17:18:07 +0200 Subject: Fix youtube comment like count after youtube update --- src/Body.cpp | 19 +++++++++++-------- src/plugins/Youtube.cpp | 6 +++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Body.cpp b/src/Body.cpp index 8cc139c..3e05a78 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -469,6 +469,7 @@ namespace QuickMedia { } mouse_left_clicked = false; + clicked_body_item = nullptr; return; } @@ -647,14 +648,6 @@ namespace QuickMedia { window.setView(prev_view); - mouse_left_clicked = false; - if(clicked_body_item) { - auto clicked_body_item_tmp = clicked_body_item; // tmp because below call to body_item_select_callback may call this same draw function - clicked_body_item = nullptr; - if(body_item_select_callback) - body_item_select_callback(clicked_body_item_tmp.get()); - } - const float item_target_top_diff = item_background_target_pos_y; const float item_target_bottom_diff = (item_background_target_pos_y + item_background_target_height + spacing_y) - body_size.y; if(((body_size_changed && attach_side == AttachSide::BOTTOM) || selected_item_diff < 0) && item_target_top_diff < 0.0f) { @@ -685,6 +678,14 @@ namespace QuickMedia { else page_scroll -= item_target_bottom_diff*page_scroll_speed; } + + mouse_left_clicked = false; + if(clicked_body_item) { + auto clicked_body_item_tmp = clicked_body_item; // tmp because below call to body_item_select_callback may call this same draw function + clicked_body_item = nullptr; + if(body_item_select_callback) + body_item_select_callback(clicked_body_item_tmp.get()); + } } void Body::update_dirty_state(BodyItem *body_item, float width) { @@ -1052,6 +1053,8 @@ namespace QuickMedia { } } else if(item->thumbnail_size.x > 0) { text_offset_x += image_padding_x + content_size.x; + if(!merge_with_previous) + image_height = content_size.y; } if(load_texture) diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index a93dcb6..e4f152f 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -812,11 +812,11 @@ namespace QuickMedia { body_item->thumbnail_size = body_item->thumbnail_size; } - const Json::Value &like_count_json = comment_renderer_json["likeCount"]; - if(like_count_json.isInt64()) { + std::optional vote_count = yt_json_get_text(comment_renderer_json, "voteCount"); + if(vote_count) { if(!description.empty()) description += '\n'; - description += "👍 " + std::to_string(like_count_json.asInt64()); + description += "👍 " + vote_count.value(); } const Json::Value &reply_count_json = comment_renderer_json["replyCount"]; -- cgit v1.2.3