public override async Task Initialize() { await base.Initialize(); startTimeEntryStopwatch = stopwatchProvider.Get(MeasuredOperation.OpenStartView); stopwatchProvider.Remove(MeasuredOperation.OpenStartView); defaultWorkspace = await interactorFactory.GetDefaultWorkspace() .TrackException <InvalidOperationException, IThreadSafeWorkspace>("StartTimeEntryViewModel.Initialize") .Execute(); canCreateProjectsInWorkspace = await interactorFactory.GetAllWorkspaces().Execute().Select(allWorkspaces => allWorkspaces.Any(ws => ws.IsEligibleForProjectCreation())); if (initialParameters != null) { var spans = new List <ISpan>(); spans.Add(new TextSpan(initialParameters.EntryDescription)); if (initialParameters.ProjectId != null) { try { var project = await interactorFactory.GetProjectById((long)initialParameters.ProjectId).Execute(); spans.Add(new ProjectSpan(project)); } catch { // Intentionally left blank } } if (initialParameters.TagIds != null) { try { var tags = initialParameters.TagIds.ToObservable() .SelectMany <long, IThreadSafeTag>(tagId => interactorFactory.GetTagById(tagId).Execute()) .ToEnumerable(); spans.AddRange(tags.Select(tag => new TagSpan(tag))); } catch { // Intentionally left blank } } textFieldInfo.Accept(textFieldInfo.Value.ReplaceSpans(spans.ToImmutableList())); } else { textFieldInfo.Accept(Autocomplete.TextFieldInfo.Empty(parameter?.WorkspaceId ?? defaultWorkspace.Id)); } hasAnyTags = (await DataSource.Tags.GetAll()).Any(); hasAnyProjects = (await DataSource.Projects.GetAll()).Any(); }
private IEnumerable <AutocompleteSuggestion> filter(IEnumerable <AutocompleteSuggestion> suggestions) { suggestionsRenderingStopwatch = stopwatchProvider.Create(MeasuredOperation.StartTimeEntrySuggestionsRenderingTime); suggestionsRenderingStopwatch.Start(); if (textFieldInfo.Value.HasProject && !isSuggestingProjects.Value && !isSuggestingTags.Value) { var projectId = textFieldInfo.Value.Spans.OfType <ProjectSpan>().Single().ProjectId; return(suggestions.OfType <TimeEntrySuggestion>() .Where(suggestion => suggestion.ProjectId == projectId)); } return(suggestions); }
public void StopSuggestionsRenderingStopwatch() { suggestionsRenderingStopwatch?.Stop(); suggestionsRenderingStopwatch = null; }
public override void ViewAppeared() { base.ViewAppeared(); startTimeEntryStopwatch?.Stop(); startTimeEntryStopwatch = null; }