protected override void OnInitialized() { base.OnInitialized(); ImportService.MatchUpdated = match => { var existing = MatchList.FirstOrDefault(m => m.Id == match.Id); if (existing == null) { MatchList.Add(match); } else { existing.Group = match.Group; existing.LocalizedNames = match.LocalizedNames; existing.MatchTeams = match.MatchTeams; existing.Number = match.Number; existing.PlaceHolderAway = match.PlaceHolderAway; existing.PlaceHolderHome = match.PlaceHolderHome; } StateHasChanged(); }; Resources.CultureChanged += (e, a) => { StateHasChanged(); }; }
/// <summary> /// Download all updates of matches /// </summary> private async void ForceDownloadMatches() { ConnectionStatus = Properties.Resources.tinder_update_getting_matches; try { bool setUpMatchList = false; var updates = await TinderHelper.GetUpdates(); // FIXME For 200 matches this hangs for ~10s foreach (var item in updates.Matches.Where(x => x.Person != null)) { var match = MatchList.FirstOrDefault(x => x.Person.Id == item.Person.Id); if (match != null) { SerializationHelper.UpdateMatchModel(match, item); } else { MatchList.Add(item); setUpMatchList = true; } } if (setUpMatchList) { MatchListSetup(); } Messenger.Default.Send(new SerializationPacket(MatchList), MessengerToken.ShowSerializationDialog); ConnectionStatus = Properties.Resources.tinder_auth_okay; } catch (TinderRequestException e) { MessageBox.Show(e.Message); } }