Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions Libs/PandoraSharp/Pandora.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,35 +349,36 @@ public async Task<List<Station>> RefreshStationsAsync()
JObject req = new JObject();
req["includeStationArtUrl"] = true;
var stationList = await CallRPC("user.getStationList", req);
// Use this local variable throughout the method.
List<Station> localStations = new List<Station>();
List<Station> combinedStations;

// Lock all modifications to the station lists
lock (_stationListLock)
{

QuickMixStationIDs.Clear();

Stations = new List<Station>();
var fetchedStations = new List<Station>();
var stations = stationList.Result["stations"];
foreach (JToken d in stations)
{
Stations.Add(new Station(this, d));
fetchedStations.Add(new Station(this, d));
}
//foreach (PDict s in stationList)
// Stations.Add(new Station(this, s));

if (QuickMixStationIDs.Count > 0)
{
foreach (Station s in Stations)
foreach (Station s in fetchedStations)
{
if (QuickMixStationIDs.Contains(s.ID))
s.UseQuickMix = true;
}
}

List<Station> quickMixes = Stations.FindAll(x => x.IsQuickMix);
Stations = Stations.FindAll(x => !x.IsQuickMix);
var quickMixes = fetchedStations.Where(x => x.IsQuickMix).ToList();
var regularStations = fetchedStations.Where(x => !x.IsQuickMix).ToList();

Stations = regularStations;

switch (StationSortOrder)
{
Expand Down Expand Up @@ -406,14 +407,17 @@ public async Task<List<Station>> RefreshStationsAsync()

}

localStations.InsertRange(0, quickMixes);
var sortedStations = Stations;
combinedStations = new List<Station>(quickMixes.Count + sortedStations.Count);
combinedStations.AddRange(quickMixes);
combinedStations.AddRange(sortedStations);
// Also update the public property for other parts of your app
this.Stations = localStations;
this.Stations = combinedStations;

} // end of lock
if (StationUpdateEvent != null)
StationUpdateEvent(this);
return localStations;
return combinedStations;
}

//private string getSyncKey()
Expand Down