@@ -17,11 +17,21 @@ ContextMenu::ContextMenu(const jellyfin::Item& item) : itemId(item.Id) {
1717 });
1818 this ->cancel ->addGestureRecognizer (new brls::TapGestureRecognizer (this ->cancel ));
1919
20- this ->btnFavorite ->registerClickAction ([this ](brls::View* view) { return this ->doFavorite (); });
20+ this ->btnFavorite ->registerClickAction ([this ](brls::View* view) {
21+ if (this ->btnFavorite ->getSelected ())
22+ return this ->unFavorite ();
23+ else
24+ return this ->doFavorite ();
25+ });
2126 this ->btnFavorite ->addGestureRecognizer (new brls::TapGestureRecognizer (this ->btnFavorite ));
2227 this ->btnFavorite ->setSelected (item.UserData .IsFavorite );
2328
24- this ->btnMarkPlay ->registerClickAction ([this ](brls::View* view) { return this ->doPlayed (); });
29+ this ->btnMarkPlay ->registerClickAction ([this ](brls::View* view) {
30+ if (this ->btnMarkPlay ->getSelected ())
31+ return this ->unPlayed ();
32+ else
33+ return this ->doPlayed ();
34+ });
2535 this ->btnMarkPlay ->addGestureRecognizer (new brls::TapGestureRecognizer (this ->btnMarkPlay ));
2636 this ->btnMarkPlay ->setSelected (item.UserData .Played );
2737}
@@ -63,5 +73,37 @@ bool ContextMenu::doFavorite() {
6373 },
6474 jellyfin::apiFavoriteItems, AppConfig::instance ().getUserId (), this ->itemId );
6575
76+ return true ;
77+ }
78+
79+ bool ContextMenu::unPlayed () {
80+ ASYNC_RETAIN
81+ jellyfin::deleteJSON<jellyfin::UserDataResult>(
82+ [ASYNC_TOKEN ](const jellyfin::UserDataResult& r) {
83+ ASYNC_RELEASE
84+ this ->btnMarkPlay ->setSelected (r.IsFavorite );
85+ },
86+ [ASYNC_TOKEN ](const std::string& ex) {
87+ ASYNC_RELEASE
88+ brls::Application::popActivity (brls::TransitionAnimation::NONE , [ex]() { brls::Application::notify (ex); });
89+ },
90+ jellyfin::apiPlayedItems, AppConfig::instance ().getUserId (), this ->itemId );
91+
92+ return true ;
93+ }
94+
95+ bool ContextMenu::unFavorite () {
96+ ASYNC_RETAIN
97+ jellyfin::deleteJSON<jellyfin::UserDataResult>(
98+ [ASYNC_TOKEN ](const jellyfin::UserDataResult& r) {
99+ ASYNC_RELEASE
100+ this ->btnFavorite ->setSelected (r.IsFavorite );
101+ },
102+ [ASYNC_TOKEN ](const std::string& ex) {
103+ ASYNC_RELEASE
104+ brls::Application::popActivity (brls::TransitionAnimation::NONE , [ex]() { brls::Application::notify (ex); });
105+ },
106+ jellyfin::apiFavoriteItems, AppConfig::instance ().getUserId (), this ->itemId );
107+
66108 return true ;
67109}
0 commit comments