Skip to content

Commit

Permalink
Fix possible channels duplicates when importing multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
laurencee committed Jul 3, 2016
1 parent bd3beea commit 29981e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("2.5.0.0")]
[assembly: AssemblyFileVersion("2.5.0.0")]
[assembly: AssemblyVersion("2.5.1.0")]
[assembly: AssemblyFileVersion("2.5.1.0")]
11 changes: 7 additions & 4 deletions Livestream.Monitor/Model/Monitoring/MonitorStreamsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,13 @@ public async Task ImportFollows(string username, IApiClient apiClient)
var followedChannelsQueryResults = await apiClient.GetUserFollows(username);
followedChannelsQueryResults.EnsureAllQuerySuccess();

var newChannels = followedChannelsQueryResults.Select(x => x.ChannelIdentifier).ToList();
Livestreams.AddRange(followedChannelsQueryResults.Select(x => x.LivestreamModel));
newChannels.ForEach(x => x.ApiClient.AddChannelWithoutQuerying(x));
AddChannels(newChannels.ToArray());
// Ignore duplicate channels
var newChannels = followedChannelsQueryResults.Where(x => !channelIdentifiers.Contains(x.ChannelIdentifier)).ToList();
if (newChannels.Count == 0) return;

Livestreams.AddRange(newChannels.Select(x => x.LivestreamModel));
newChannels.ForEach(x => x.ChannelIdentifier.ApiClient.AddChannelWithoutQuerying(x.ChannelIdentifier));
AddChannels(newChannels.Select(x => x.ChannelIdentifier).ToArray());
await RefreshLivestreams();
}

Expand Down

0 comments on commit 29981e0

Please sign in to comment.