Skip to content

Commit ceb85b8

Browse files
committed
first attempt at fixing #9 --very tricky
1 parent d4c2ada commit ceb85b8

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

Sparkfly.Main/Services/SparkflyManager.cs

+8-11
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,13 @@ private void ResetPriority(int priority)
158158

159159
public void EnqueueVote(Track votedTrack, Client client)
160160
{
161-
int priority = 0; // lower number means higher priority
161+
int priority; // lower number means higher priority
162162

163-
for (priority = 0; priority < Votes.Count; priority++)
164-
{
165-
if (Votes[priority].Any(v => v.Client.Id == client.Id))
166-
continue;
167-
168-
break;
169-
}
163+
for (priority = Votes.Count; priority > 0; priority--)
164+
if (Votes[priority - 1].Any(v => v.Client.Id == client.Id))
165+
break;
170166

171-
if (priority == 0 && PreviouslyPlayedVotes.Any(v => v.Client.Id == client.Id))
167+
if (priority == 0 && Votes.Any() && (CurrentlyPlayingVote.Client.Id == client.Id || PreviouslyPlayedVotes.Any(v => v.Client.Id == client.Id)))
172168
priority = 1;
173169

174170
if (priority >= Votes.Count)
@@ -208,7 +204,7 @@ public void RemoveVote(Track track, Client client)
208204
}
209205

210206
OnVotingQueueUpdate();
211-
}
207+
}
212208
#endregion
213209

214210
#region Timer Methods
@@ -241,9 +237,10 @@ private async void OnTimerElapsedAsync(object source, EventArgs args)
241237
{
242238
if (nextVote is not null && newestTrack.SongId == nextVote.VotedTrack.SongId)
243239
{
240+
PreviouslyPlayedVotes.Add(CurrentlyPlayingVote);
241+
244242
TryDequeueVote();
245243

246-
PreviouslyPlayedVotes.Add(CurrentlyPlayingVote);
247244
CurrentlyPlayingVote = nextVote;
248245
}
249246
else

0 commit comments

Comments
 (0)