Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/clearSuggestions function #3

Open
pironic opened this issue Sep 24, 2014 · 1 comment
Open

/clearSuggestions function #3

pironic opened this issue Sep 24, 2014 · 1 comment
Assignees

Comments

@pironic
Copy link
Member

pironic commented Sep 24, 2014

it would approve everything in the suggestions, then remove from the end of queue.

var suggestions = GS.getCurrentBroadcast().attributes.suggestions.models;
var number = suggestions.length;
suggestions.forEach(function(suggestion) {
    GS.Services.SWF.approveSuggestedSongForBroadcast(suggestion.attributes.SongID)
});
var songs = GS.Services.SWF.getCurrentQueue().songs;
if (isNaN(number) || number < 1)
    number = 0;
while (--number >= 0)
{
    if (songs.length - 1 - number >= 0)
    {
        var id = songs[songs.length - 1 - number].queueSongID;
        if (id != GS.Services.SWF.getCurrentQueue().activeSong.queueSongID)
            allID.push(id);
    }
}
if (allID.length > 0)
{
    GS.Services.SWF.removeSongs(allID);
}
@pironic
Copy link
Member Author

pironic commented Sep 24, 2014

had to alter slightly... apparently its not instant. who knew..

var suggestions = GS.getCurrentBroadcast().attributes.suggestions.models;
var number = suggestions.length;
var allID = [];
suggestions.forEach(function(suggestion) {
    GS.Services.SWF.approveSuggestedSongForBroadcast(suggestion.attributes.SongID)
});
setTimeout(function(){
    var songs = GS.Services.SWF.getCurrentQueue().songs;
    while (--number >= 0)
    {
        if (songs.length - 1 - number >= 0)
        {
            var id = songs[songs.length - 1 - number].queueSongID;
            allID.push(id);
        }
    }
    GS.Services.SWF.removeSongs(allID);
}, 5000);

@pironic pironic self-assigned this Sep 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant