/// <summary> /// Reset all tracking variables. /// </summary> public void Reset() { VotesWithSupporters.Clear(); VoterMessageId.Clear(); RankedVotesWithSupporters.Clear(); RankedVoterMessageId.Clear(); PlanNames.Clear(); ReferenceVoters.Clear(); ReferenceVoterPosts.Clear(); ReferencePlanNames.Clear(); ReferencePlans.Clear(); FutureReferences.Clear(); UndoBuffer.Clear(); OrderedTaskList.Clear(); cleanVoteLookup.Clear(); cleanedKeys.Clear(); if (VotesWithSupporters.Comparer != Agnostic.StringComparer) { VotesWithSupporters = new Dictionary <string, HashSet <string> >(Agnostic.StringComparer); } if (RankedVotesWithSupporters.Comparer != Agnostic.StringComparer) { RankedVotesWithSupporters = new Dictionary <string, HashSet <string> >(Agnostic.StringComparer); } OnPropertyChanged("VoteCounter"); OnPropertyChanged("Tasks"); }
/// <summary> /// Construct the tally results based on the stored list of posts. /// Run async so that it doesn't cause UI jank. /// </summary> /// <param name="token">Cancellation token.</param> public async Task TallyPosts(CancellationToken token) { if (Quest == null) { return; } try { VoteCounterIsTallying = true; TallyWasCanceled = false; Reset(); if (PostsList == null || PostsList.Count == 0) { return; } await PreprocessPlans(token).ConfigureAwait(false); await ProcessPosts(token).ConfigureAwait(false); } catch (OperationCanceledException) { TallyWasCanceled = true; } finally { VoteCounterIsTallying = false; } OrderedTaskList.AddRange(ViewModelService.MainViewModel.KnownTasks); OnPropertyChanged("Tasks"); }
/// <summary> /// Run the tally using the provided posts, for the selected quest. /// </summary> /// <param name="posts">The posts to be tallied.</param> /// <param name="quest">The quest being tallied.</param> /// <param name="token">Cancellation token.</param> public async Task TallyPosts(IEnumerable <PostComponents> posts, IQuest quest, CancellationToken token) { Quest = quest; PostsList.Clear(); PostsList.AddRange(posts); await TallyPosts(token).ConfigureAwait(false); OrderedTaskList.AddRange(ViewModelService.MainViewModel.KnownTasks); OnPropertyChanged("Tasks"); }