Commit de6a151f authored by Kevin Whitaker's avatar Kevin Whitaker

Clean up some things. Make skip vote longer. Put in js that should show...

Clean up some things. Make skip vote longer. Put in js that should show notifications for skip requests.
parent 249e34f3
......@@ -540,7 +540,7 @@ GroovePlayerMgr::PlayerEvent GroovePlayerMgr::getNextPlayerEvent(Wt::Dbo::Sessio
return PlayerEvent() = {PlayerEventType::GROOVE_NOWPLAYING};
}
}
if(!voteEndedButNotNextTrackYet && currentSkipRequester.size() > 0 && skipRequestedAt+std::chrono::seconds(5) < std::chrono::steady_clock::now())
if(!voteEndedButNotNextTrackYet && currentSkipRequester.size() > 0 && skipRequestedAt+std::chrono::seconds(10) < std::chrono::steady_clock::now())
{
//Skip succeeded. Time to skip song.
lastInternalEvents.push_front(PlayerEvent() = {PlayerEventType::SKIP_VOTING_ENDED});
......
......@@ -45,6 +45,7 @@ WebInterface::WebInterface(const Wt::WEnvironment& env) : Wt::WApplication(env)
root()->addWidget(priv_int->loginUI);
priv_int->loginUI->animateShow(Wt::WAnimation(Wt::WAnimation::AnimationEffect::SlideInFromTop));
priv_int->loginUI->checkSessionValidity();
notificationSlot.setJavaScript(getNotificationJs(""));
}
WebInterface::~WebInterface()
......@@ -79,7 +80,9 @@ void WebInterface::songChangedFromServer(AudioTrack nextTrack)
void WebInterface::skipVotedFromServer(User userRequestingToSkipCurrentTrack)
{
priv_int->playerUI->updateSkipRequestedFromServer();
//TODO: show notification
//show notification
notificationSlot.setJavaScript(getNotificationJs(userRequestingToSkipCurrentTrack.username+" has requested to skip "+GroovePlayerMgr::getInstance()->currentTrack.trackName+"."));
notificationSlot.exec();
triggerUpdate();
}
......@@ -106,3 +109,8 @@ void WebInterface::voteTracksUpdatedFromServer(std::list<AudioTrack> voteableTra
priv_int->playerUI->updateVoteableTracksFromServer(voteableTracks);
triggerUpdate();
}
std::string WebInterface::getNotificationJs(std::string notificationText)
{
return std::string("function notifyMe(a,b){var c='")+notificationText+std::string("';if('Notification'in window)if('granted'===Notification.permission){new Notification(c)}else'denied'!==Notification.permission&&Notification.requestPermission(function(a){if('granted'===a){new Notification(c)}});else;}");
}
......@@ -24,6 +24,7 @@
#include "GroovePlayer.h"
#include "db/AudioTrack.h"
#include "db/User.h"
#include <Wt/WJavaScript>
class WebInterface : public Wt::WApplication
{
......@@ -42,6 +43,8 @@ public:
private:
struct internal;
internal* priv_int = 0;
std::string getNotificationJs(std::string message);
Wt::JSlot notificationSlot;
};
#endif // WEBINTERFACE_H
......@@ -70,10 +70,6 @@ public:
bool isPaused = false;
//TODO:put in controls for requesting/admin skip and adding users as admin.
//Vote controls
//TODO:put in vote controls for seeing tracks to vote on and vote buttons.
//TODO:put in controls for requesting songs.
void playpauseClicked();
void playpauseUpdated();
void skipRequestClicked();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment