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

This commit is contained in:
Kevin Whitaker
2017-02-18 23:13:13 -05:00
parent 249e34f3c7
commit de6a151fd0
4 changed files with 13 additions and 6 deletions

View File

@@ -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;}");
}