Clean up some things. Make skip vote longer. Put in js that should show notifications for skip requests.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user