diff --git a/resources/svg/bpx-svg-sprite-disliked-active.svg b/resources/svg/bpx-svg-sprite-disliked-active.svg new file mode 100644 index 00000000..b9f43b20 --- /dev/null +++ b/resources/svg/bpx-svg-sprite-disliked-active.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/resources/svg/bpx-svg-sprite-disliked.svg b/resources/svg/bpx-svg-sprite-disliked.svg new file mode 100644 index 00000000..6d9926e7 --- /dev/null +++ b/resources/svg/bpx-svg-sprite-disliked.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/resources/svg/comment-disagree-active.svg b/resources/svg/comment-disagree-active.svg new file mode 100644 index 00000000..b9f43b20 --- /dev/null +++ b/resources/svg/comment-disagree-active.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/resources/svg/comment-disagree-grey.svg b/resources/svg/comment-disagree-grey.svg new file mode 100644 index 00000000..6d9e01b4 --- /dev/null +++ b/resources/svg/comment-disagree-grey.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/resources/xml/fragment/player_comment_action.xml b/resources/xml/fragment/player_comment_action.xml index a2cf94a2..5e0edc1c 100644 --- a/resources/xml/fragment/player_comment_action.xml +++ b/resources/xml/fragment/player_comment_action.xml @@ -45,6 +45,16 @@ highlightCornerRadius="48" SVG="@res/svg/bpx-svg-sprite-reply.svg"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/xml/views/video_comment.xml b/resources/xml/views/video_comment.xml index f89d91d7..c74593e7 100644 --- a/resources/xml/views/video_comment.xml +++ b/resources/xml/views/video_comment.xml @@ -52,10 +52,16 @@ + & callback = nullptr, const ErrorCallback& error = nullptr); @@ -419,15 +419,21 @@ class BilibiliClient { const ErrorCallback& error = nullptr); /// 获取单条评论详情 - static void get_comment_detail(const std::string& access_key, const std::string& oid, int64_t rpid, size_t next = 0, + static void get_comment_detail(const std::string& access_key, const std::string& oid, uint64_t rpid, size_t next = 0, int type = 1, const std::function& callback = nullptr, const ErrorCallback& error = nullptr); /// 点赞评论 - static void be_agree_comment(const std::string& access_key, const std::string& oid, int64_t rpid, bool is_like, + static void be_agree_comment(const std::string& access_key, const std::string& oid, uint64_t rpid, bool is_like, int type = 1, const std::function& callback = nullptr, const ErrorCallback& error = nullptr); + + /// 点踩评论 + static void be_disagree_comment(const std::string& access_key, const std::string& oid, uint64_t rpid, bool is_dislike, + int type = 1, const std::function& callback = nullptr, + const ErrorCallback& error = nullptr); + /// 点赞动态 static void be_agree_dynamic(const std::string& access_key, const std::string& id, bool is_like, const std::function& callback = nullptr, const ErrorCallback& error = nullptr); @@ -443,12 +449,12 @@ class BilibiliClient { * @param error */ static void add_comment(const std::string& access_key, const std::string& message, const std::string& oid, - int64_t parent = 0, int64_t root = 0, int type = 1, + uint64_t parent = 0, uint64_t root = 0, int type = 1, const std::function& callback = nullptr, const ErrorCallback& error = nullptr); /// 删除评论 - static void delete_comment(const std::string& access_key, const std::string& oid, int64_t rpid, int type = 1, + static void delete_comment(const std::string& access_key, const std::string& oid, uint64_t rpid, int type = 1, const std::function& callback = nullptr, const ErrorCallback& error = nullptr); /// 视频页 获取单个视频播放人数 diff --git a/wiliwili/include/api/bilibili/api.h b/wiliwili/include/api/bilibili/api.h index 43be6bea..48546008 100644 --- a/wiliwili/include/api/bilibili/api.h +++ b/wiliwili/include/api/bilibili/api.h @@ -142,6 +142,8 @@ const std::string Comment = _apiBase + "/x/v2/reply/main"; const std::string CommentDetail = _apiBase + "/x/v2/reply/detail"; /// 点赞评论 const std::string CommentLike = _apiBase + "/x/v2/reply/action"; +/// 点踩评论 +const std::string CommentDisLike = _apiBase + "/x/v2/reply/hate"; /// 发布评论 const std::string CommentAdd = _apiBase + "/x/v2/reply/add"; /// 删除评论 diff --git a/wiliwili/include/api/bilibili/result/mine_collection_result.h b/wiliwili/include/api/bilibili/result/mine_collection_result.h index 9208d900..4f8ba2f3 100644 --- a/wiliwili/include/api/bilibili/result/mine_collection_result.h +++ b/wiliwili/include/api/bilibili/result/mine_collection_result.h @@ -19,8 +19,8 @@ namespace bilibili { class SimpleCollectionList { public: - int64_t id; - int64_t fid; + uint64_t id; + uint64_t fid; uint64_t mid; unsigned int attr; std::string title; @@ -41,8 +41,8 @@ typedef std::vector SimpleCollectionListResult; class CollectionResult { public: - int64_t id = 0; - int64_t fid = 0; + uint64_t id = 0; + uint64_t fid = 0; int type = SUBSCRIPTION_TYPE_2; // 视频列表的类型, 11: 收藏夹 21: 合集 std::string cover; std::string title; diff --git a/wiliwili/include/fragment/player_single_comment.hpp b/wiliwili/include/fragment/player_single_comment.hpp index d9e8bb97..6867d7d2 100644 --- a/wiliwili/include/fragment/player_single_comment.hpp +++ b/wiliwili/include/fragment/player_single_comment.hpp @@ -44,7 +44,7 @@ class PlayerSingleComment : public brls::Box { void showDismissAnimation(); - brls::Event likeStateEvent; + brls::Event likeStateEvent; brls::Event likeNumEvent; brls::Event replyNumEvent; brls::Event<> deleteEvent; @@ -76,7 +76,8 @@ class PlayerCommentAction : public brls::Box { void dismiss(std::function cb = nullptr) override; - brls::Event<> likeClickEvent, replyClickEvent, deleteClickEvent; + brls::Event<> replyClickEvent, deleteClickEvent; + brls::Event likeClickEvent; void showStartAnimation(); @@ -85,6 +86,7 @@ class PlayerCommentAction : public brls::Box { private: BRLS_BIND(SVGImage, svgReply, "comment/action/svg/reply"); BRLS_BIND(SVGImage, svgLike, "comment/action/svg/like"); + BRLS_BIND(SVGImage, svgDisLike, "comment/action/svg/dislike"); BRLS_BIND(SVGImage, svgDelete, "comment/action/svg/delete"); BRLS_BIND(SVGImage, svgGallery, "comment/action/svg/gallery"); BRLS_BIND(brls::Box, actionBox, "comment/action/box"); diff --git a/wiliwili/include/presenter/comment_related.hpp b/wiliwili/include/presenter/comment_related.hpp index 75e39d5b..caccd26f 100644 --- a/wiliwili/include/presenter/comment_related.hpp +++ b/wiliwili/include/presenter/comment_related.hpp @@ -11,12 +11,14 @@ class CommentAction : public Presenter { public: virtual void onError(const std::string& error); - void commentLike(const std::string& oid, int64_t rpid, int action, int type); + void commentLike(const std::string& oid, uint64_t rpid, bool action, int type); - void commentReply(const std::string& text, const std::string& oid, int64_t rpid, int64_t root, int type, - std::function cb = nullptr); + void commentDislike(const std::string& oid, uint64_t rpid, bool action, int type); - void commentDelete(const std::string& oid, int64_t rpid, int type); + void commentReply(const std::string& text, const std::string& oid, uint64_t rpid, uint64_t root, int type, + const std::function& cb = nullptr); + + void commentDelete(const std::string& oid, uint64_t rpid, int type); }; class CommentRequest : public Presenter { @@ -42,7 +44,7 @@ class CommentRequest : public Presenter { bool end = false; }; -class DynamicAction: public Presenter { +class DynamicAction : public Presenter { public: virtual void onError(const std::string& error); diff --git a/wiliwili/include/view/dynamic_article.hpp b/wiliwili/include/view/dynamic_article.hpp index a06efd8f..9e1ed73e 100644 --- a/wiliwili/include/view/dynamic_article.hpp +++ b/wiliwili/include/view/dynamic_article.hpp @@ -33,7 +33,7 @@ class DynamicArticleDetail : public brls::Box, public CommentRequest, public Dyn void toggleCommentMode(); - brls::Event likeStateEvent; + brls::Event likeStateEvent; brls::Event likeNumEvent; private: diff --git a/wiliwili/include/view/video_comment.hpp b/wiliwili/include/view/video_comment.hpp index 2374ea80..a66de1a2 100644 --- a/wiliwili/include/view/video_comment.hpp +++ b/wiliwili/include/view/video_comment.hpp @@ -63,7 +63,7 @@ class VideoComment : public RecyclingGridItem { void setLikeNum(size_t num); - void setLiked(bool liked); + void setLiked(size_t action); bilibili::VideoCommentResult getData(); @@ -83,5 +83,6 @@ class VideoComment : public RecyclingGridItem { BRLS_BIND(SVGImage, userLevel, "comment/user/level"); BRLS_BIND(SVGImage, svgReply, "comment/svg/reply"); BRLS_BIND(SVGImage, svgLike, "comment/svg/like"); + BRLS_BIND(SVGImage, svgDislike, "comment/svg/dislike"); bilibili::VideoCommentResult comment_data; }; \ No newline at end of file diff --git a/wiliwili/source/activity/player_base_activity.cpp b/wiliwili/source/activity/player_base_activity.cpp index 3b8362fb..fc895304 100644 --- a/wiliwili/source/activity/player_base_activity.cpp +++ b/wiliwili/source/activity/player_base_activity.cpp @@ -87,7 +87,7 @@ class DataSourceCommentList : public RecyclingGridDataSource, public CommentActi container->setInFadeAnimation(true); brls::Application::pushActivity(new brls::Activity(container)); - view->likeStateEvent.subscribe([this, item, index](bool value) { + view->likeStateEvent.subscribe([this, item, index](size_t value) { auto& itemData = dataList[index - 2]; itemData.action = value; item->setLiked(value); diff --git a/wiliwili/source/api/mine_api.cpp b/wiliwili/source/api/mine_api.cpp index aa778236..0e10b569 100644 --- a/wiliwili/source/api/mine_api.cpp +++ b/wiliwili/source/api/mine_api.cpp @@ -289,7 +289,7 @@ void BilibiliClient::get_collection_list_all(uint64_t rid, int type, const std:: error); } -void BilibiliClient::get_collection_video_list(int64_t id, int index, int num, int type, +void BilibiliClient::get_collection_video_list(uint64_t id, int index, int num, int type, const std::function& callback, const ErrorCallback& error) { HTTP::getResultAsync( diff --git a/wiliwili/source/api/video_detail_api.cpp b/wiliwili/source/api/video_detail_api.cpp index b5396605..88a37718 100644 --- a/wiliwili/source/api/video_detail_api.cpp +++ b/wiliwili/source/api/video_detail_api.cpp @@ -127,7 +127,7 @@ void BilibiliClient::get_comment(const std::string& oid, int next, int mode, int error); } -void BilibiliClient::get_comment_detail(const std::string& access_key, const std::string& oid, int64_t rpid, +void BilibiliClient::get_comment_detail(const std::string& access_key, const std::string& oid, uint64_t rpid, size_t next, int type, const std::function& callback, const ErrorCallback& error) { @@ -360,7 +360,7 @@ void BilibiliClient::be_agree(const std::string& access_key, uint64_t aid, bool HTTP::postResultAsync(Api::LikeWeb, {}, payload, callback, error); } -void BilibiliClient::be_agree_comment(const std::string& access_key, const std::string& oid, int64_t rpid, bool is_like, +void BilibiliClient::be_agree_comment(const std::string& access_key, const std::string& oid, uint64_t rpid, bool is_like, int type, const std::function& callback, const ErrorCallback& error) { cpr::Payload payload = { {"oid", oid}, {"rpid", std::to_string(rpid)}, {"action", is_like ? "1" : "0"}, @@ -369,6 +369,15 @@ void BilibiliClient::be_agree_comment(const std::string& access_key, const std:: HTTP::postResultAsync(Api::CommentLike, {}, payload, callback, error); } +void BilibiliClient::be_disagree_comment(const std::string& access_key, const std::string& oid, uint64_t rpid, bool is_dislike, + int type, const std::function& callback, const ErrorCallback& error) { + cpr::Payload payload = { + {"oid", oid}, {"rpid", std::to_string(rpid)}, {"action", is_dislike ? "1" : "0"}, + {"csrf", access_key}, {"type", std::to_string(type)}, {"ordering", "heat"}, + }; + HTTP::postResultAsync(Api::CommentDisLike, {}, payload, callback, error); +} + void BilibiliClient::ugc_season_subscribe(int id, const std::string& csrf, const std::function& callback, const ErrorCallback& error) { cpr::Payload payload = { @@ -389,7 +398,7 @@ void BilibiliClient::ugc_season_unsubscribe(int id, const std::string& csrf, con HTTP::postResultAsync(Api::UGCSeasonUnsubscribe, {}, payload, callback, error); } -void BilibiliClient::delete_comment(const std::string& access_key, const std::string& oid, int64_t rpid, int type, +void BilibiliClient::delete_comment(const std::string& access_key, const std::string& oid, uint64_t rpid, int type, const std::function& callback, const ErrorCallback& error) { cpr::Payload payload = { {"oid", oid}, @@ -401,7 +410,7 @@ void BilibiliClient::delete_comment(const std::string& access_key, const std::st } void BilibiliClient::add_comment(const std::string& access_key, const std::string& message, const std::string& oid, - int64_t parent, int64_t root, int type, + uint64_t parent, uint64_t root, int type, const std::function& callback, const ErrorCallback& error) { cpr::Payload payload = { diff --git a/wiliwili/source/fragment/player_single_comment.cpp b/wiliwili/source/fragment/player_single_comment.cpp index 494823c8..32523468 100644 --- a/wiliwili/source/fragment/player_single_comment.cpp +++ b/wiliwili/source/fragment/player_single_comment.cpp @@ -56,7 +56,7 @@ class GridRelatedView : public RecyclingGridItem { class DataSourceSingleCommentList : public RecyclingGridDataSource, public CommentAction { public: DataSourceSingleCommentList(bilibili::VideoCommentListResult result, int type, CommentUiType uiType, - brls::Event* likeState, brls::Event* likeNum, + brls::Event* likeState, brls::Event* likeNum, brls::Event* replyNum, brls::Event<>* deleteReply) : dataList(std::move(result)), commentType(type), @@ -114,10 +114,19 @@ class DataSourceSingleCommentList : public RecyclingGridDataSource, public Comme container->setInFadeAnimation(true); brls::Application::pushActivity(new brls::Activity(container)); - view->likeClickEvent.subscribe([this, item, index]() { + view->likeClickEvent.subscribe([this, item, index](size_t action) { auto& itemData = dataList[index]; - itemData.action = !itemData.action; - itemData.like += itemData.action ? 1 : -1; + // 点赞/取消点赞 或 点踩/取消点踩 + bool isLike = action == 1 || (action == 0 & itemData.action == 1); + if (action == 1) { + // 最新状态变为点赞,点赞数 +1 + itemData.like++; + } else if (itemData.action == 1) { + // 最新状态由点赞转为 取消或点踩,点赞数 -1 + itemData.like--; + } + + itemData.action = action; item->setLiked(itemData.action); item->setLikeNum(itemData.like); @@ -127,7 +136,11 @@ class DataSourceSingleCommentList : public RecyclingGridDataSource, public Comme likeNum->fire(itemData.like); } - this->commentLike(std::to_string(itemData.oid), itemData.rpid, itemData.action, commentType); + if (isLike) { + this->commentLike(std::to_string(itemData.oid), itemData.rpid, itemData.action, commentType); + } else { + this->commentDislike(std::to_string(itemData.oid), itemData.rpid, itemData.action, commentType); + } }); view->replyClickEvent.subscribe([this, index, recycler]() { @@ -213,7 +226,7 @@ class DataSourceSingleCommentList : public RecyclingGridDataSource, public Comme bilibili::VideoCommentListResult dataList; int commentType; CommentUiType uiType; - brls::Event* likeState; + brls::Event* likeState; brls::Event* likeNum; brls::Event* replyNum; brls::Event<>* deleteReply; @@ -396,7 +409,11 @@ brls::View* PlayerSingleComment::getDefaultFocus() { return this->recyclingGrid; PlayerCommentAction::PlayerCommentAction(CommentUiType type) { if (type == COMMENT_UI_TYPE_DYNAMIC) { - this->inflateFromXMLRes("xml/fragment/player_comment_action_dynamic.xml"); + if (brls::Application::ORIGINAL_WINDOW_HEIGHT < 720) { + this->inflateFromXMLRes("xml/fragment/player_comment_action_dynamic_sm.xml"); + } else { + this->inflateFromXMLRes("xml/fragment/player_comment_action_dynamic.xml"); + } } else { this->inflateFromXMLRes("xml/fragment/player_comment_action.xml"); } @@ -405,7 +422,12 @@ PlayerCommentAction::PlayerCommentAction(CommentUiType type) { this->svgLike->registerClickAction([this](...) { this->dismiss(); - this->likeClickEvent.fire(); + this->likeClickEvent.fire(this->comment->getData().action == 1 ? 0 : 1); + return true; + }); + this->svgDisLike->registerClickAction([this](...) { + this->dismiss(); + this->likeClickEvent.fire(this->comment->getData().action == 2 ? 0 : 2); return true; }); this->svgReply->registerClickAction([this](...) { @@ -441,6 +463,7 @@ PlayerCommentAction::PlayerCommentAction(CommentUiType type) { }); this->svgLike->addGestureRecognizer(new brls::TapGestureRecognizer(this->svgLike)); + this->svgDisLike->addGestureRecognizer(new brls::TapGestureRecognizer(this->svgDisLike)); this->svgReply->addGestureRecognizer(new brls::TapGestureRecognizer(this->svgReply)); this->svgDelete->addGestureRecognizer(new brls::TapGestureRecognizer(this->svgDelete)); this->svgGallery->addGestureRecognizer(new brls::TapGestureRecognizer(this->svgGallery)); diff --git a/wiliwili/source/presenter/comment_related.cpp b/wiliwili/source/presenter/comment_related.cpp index 6c59d9ae..d7f2a089 100644 --- a/wiliwili/source/presenter/comment_related.cpp +++ b/wiliwili/source/presenter/comment_related.cpp @@ -3,6 +3,7 @@ // #include +#include #include #include "bilibili.h" @@ -12,18 +13,18 @@ /// CommentAction -void CommentAction::onError(const std::string& error) { DialogHelper::showDialog(error); } +void CommentAction::onError(const std::string& error) { brls::Application::notify(error); } -void CommentAction::commentLike(const std::string& oid, int64_t rpid, int action, int type) { +void CommentAction::commentLike(const std::string& oid, uint64_t rpid, bool action, int type) { ASYNC_RETAIN BILI::be_agree_comment( ProgramConfig::instance().getCSRF(), oid, rpid, action, type, [ASYNC_TOKEN, oid, rpid, action]() { ASYNC_RELEASE - brls::Logger::debug("Comment action success: {} {} {}", oid, rpid, action); + brls::Logger::debug("Comment like success: {} {} {}", oid, rpid, action); }, [ASYNC_TOKEN, oid, rpid, action](BILI_ERR) { - brls::Logger::error("Comment action error: {} {} {}", oid, rpid, action); + brls::Logger::error("Comment like error: {} {} {}", oid, rpid, action); brls::sync([ASYNC_TOKEN, error]() { ASYNC_RELEASE this->onError(error); @@ -31,8 +32,25 @@ void CommentAction::commentLike(const std::string& oid, int64_t rpid, int action }); } -void CommentAction::commentReply(const std::string& text, const std::string& oid, int64_t rpid, int64_t root, int type, - std::function cb) { +void CommentAction::commentDislike(const std::string& oid, uint64_t rpid, bool action, int type) { + ASYNC_RETAIN + BILI::be_disagree_comment( + ProgramConfig::instance().getCSRF(), oid, rpid, action, type, + [ASYNC_TOKEN, oid, rpid, action]() { + ASYNC_RELEASE + brls::Logger::debug("Comment dislike success: {} {} {}", oid, rpid, action); + }, + [ASYNC_TOKEN, oid, rpid, action](BILI_ERR) { + brls::Logger::error("Comment dislike error: {} {} {}", oid, rpid, action); + brls::sync([ASYNC_TOKEN, error]() { + ASYNC_RELEASE + this->onError(error); + }); + }); +} + +void CommentAction::commentReply(const std::string& text, const std::string& oid, uint64_t rpid, uint64_t root, int type, + const std::function& cb) { ASYNC_RETAIN BILI::add_comment( ProgramConfig::instance().getCSRF(), text, oid, rpid, root, type, @@ -51,7 +69,7 @@ void CommentAction::commentReply(const std::string& text, const std::string& oid }); } -void CommentAction::commentDelete(const std::string& oid, int64_t rpid, int type) { +void CommentAction::commentDelete(const std::string& oid, uint64_t rpid, int type) { ASYNC_RETAIN BILI::delete_comment( ProgramConfig::instance().getCSRF(), oid, rpid, type, diff --git a/wiliwili/source/view/dynamic_article.cpp b/wiliwili/source/view/dynamic_article.cpp index 6e98dedb..49306dc3 100644 --- a/wiliwili/source/view/dynamic_article.cpp +++ b/wiliwili/source/view/dynamic_article.cpp @@ -229,7 +229,7 @@ class DynamicCommentAction : public brls::Box { class DataSourceDynamicDetailList : public RecyclingGridDataSource, public CommentAction, public DynamicAction { public: DataSourceDynamicDetailList(const bilibili::DynamicArticleResult& data, bilibili::DynamicArticleModuleState state, - brls::Event* likeState, brls::Event* likeNum, int mode, + brls::Event* likeState, brls::Event* likeNum, int mode, std::function cb) : data(data), state(std::move(state)), @@ -340,7 +340,7 @@ class DataSourceDynamicDetailList : public RecyclingGridDataSource, public Comme container->setInFadeAnimation(true); brls::Application::pushActivity(new brls::Activity(container)); - view->likeStateEvent.subscribe([this, item, index](bool value) { + view->likeStateEvent.subscribe([this, item, index](size_t value) { auto& itemData = dataList[index - 3]; itemData.action = value; item->setLiked(value); @@ -382,7 +382,7 @@ class DataSourceDynamicDetailList : public RecyclingGridDataSource, public Comme private: const bilibili::DynamicArticleResult& data; // 动态原始数据 bilibili::DynamicArticleModuleState state; // 动态赞评转数据,为方便修改,不使用 data 内的数据 - brls::Event* likeState; + brls::Event* likeState; brls::Event* likeNum; bilibili::VideoCommentListResult dataList; int commentMode = 3; // 2: 按时间;3: 按热度 @@ -764,7 +764,7 @@ void DynamicArticleView::openDetail() { this->state.like.count = num; }); - detail->likeStateEvent.subscribe([this](bool value) { + detail->likeStateEvent.subscribe([this](size_t value) { this->setLiked(value); this->state.like.like_state = value; }); diff --git a/wiliwili/source/view/video_comment.cpp b/wiliwili/source/view/video_comment.cpp index 5ab0781f..56361e7e 100644 --- a/wiliwili/source/view/video_comment.cpp +++ b/wiliwili/source/view/video_comment.cpp @@ -54,10 +54,10 @@ class CommentElementEmote : public CommentElement { class CommentElementUser : public CommentElement { public: - CommentElementUser(const std::string& name, int64_t id) + CommentElementUser(const std::string& name, uint64_t id) : CommentElement("@" + name + " ", CommentElementType::USER), name(name), id(id) {} std::string name; - int64_t id; + uint64_t id; }; class CommentElementTopic : public CommentElement { @@ -299,12 +299,8 @@ void VideoComment::setData(bilibili::VideoCommentResult data) { } // 设置点赞状态 - if (data.action) { - this->svgLike->setImageFromSVGRes("svg/comment-agree-active.svg"); - } else { - this->svgLike->setImageFromSVGRes("svg/comment-agree-grey.svg"); - } - + // action, 0: 未点赞, 1: 已点赞, 2: 已点踩 + this->setLiked(data.action); this->setLikeNum(data.like); this->setReplyNum(data.rcount); } @@ -321,12 +317,17 @@ void VideoComment::setLikeNum(size_t num) { this->labelLike->setText(wiliwili::num2w(num)); } -void VideoComment::setLiked(bool liked) { - this->comment_data.action = liked; - if (liked) { +void VideoComment::setLiked(size_t action) { + this->comment_data.action = action; + if (action == 1) { this->svgLike->setImageFromSVGRes("svg/comment-agree-active.svg"); + this->svgDislike->setImageFromSVGRes("svg/comment-disagree-grey.svg"); + } else if (action == 2) { + this->svgLike->setImageFromSVGRes("svg/comment-agree-grey.svg"); + this->svgDislike->setImageFromSVGRes("svg/comment-disagree-active.svg"); } else { this->svgLike->setImageFromSVGRes("svg/comment-agree-grey.svg"); + this->svgDislike->setImageFromSVGRes("svg/comment-disagree-grey.svg"); } }