<commit_before>﻿using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using BlueMonkey.Business;
using BlueMonkey.ExpenceServices;
using BlueMonkey.Model;
using Prism.Navigation;
using Reactive.Bindings;

namespace BlueMonkey.ViewModels
{
    public class ReportListPageViewModel : BindableBase, INavigationAware
    {
        private readonly INavigationService _navigationService;
        private readonly IReferReport _referReport;
        public ReadOnlyReactiveCollection<Report> Reports { get; }
        /// <summary>
        /// Add New Report Navigation Command.
        /// </summary>
        public DelegateCommand AddReportCommand => new DelegateCommand(AddReport);

        public DelegateCommand<Report> UpdateReportCommand => new DelegateCommand<Report>(UpdateReport);

        /// <summary>
        /// Initialize Instance
        /// </summary>
        /// <param name="navigationService"></param>
        /// <param name="referReport"></param>
        public ReportListPageViewModel(INavigationService navigationService, IReferReport referReport)
        {
            _navigationService = navigationService;
            _referReport = referReport;
            Reports = _referReport.Reports.ToReadOnlyReactiveCollection();
        }

        /// <summary>
        /// Navigation ReportPage when create Report.
        /// </summary>
        private void AddReport()
        {
            NavigateReportPage(null);
        }
        /// <summary>
        /// Navigation ReportPage when update Report.
        /// </summary>
        /// <param name="selectedReport"></param>
        private void UpdateReport(Report selectedReport)
        {
            NavigateReportPage(selectedReport.Id);
        }

        /// <summary>
        /// Navigation ReportPage.
        /// </summary>
        private void NavigateReportPage(string reportId)
        {
            var navigationParameter = new NavigationParameters();
            navigationParameter[ReportPageViewModel.ReportIdKey] = reportId;
            _navigationService.NavigateAsync("ReportPage", navigationParameter);
        }

        public void OnNavigatedFrom(NavigationParameters parameters)
        {
        }

        public void OnNavigatedTo(NavigationParameters parameters)
        {
            _referReport.SearchAsync();
        }

        public void OnNavigatingTo(NavigationParameters parameters)
        {
        }
    }
}<commit_msg>Update to wait _referReport.SearchAsync for ReportListPageViuewModel#OnNavigatedTo.<commit_after>﻿using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using BlueMonkey.Business;
using BlueMonkey.ExpenceServices;
using BlueMonkey.Model;
using Prism.Navigation;
using Reactive.Bindings;

namespace BlueMonkey.ViewModels
{
    public class ReportListPageViewModel : BindableBase, INavigationAware
    {
        private readonly INavigationService _navigationService;
        private readonly IReferReport _referReport;
        public ReadOnlyReactiveCollection<Report> Reports { get; }
        /// <summary>
        /// Add New Report Navigation Command.
        /// </summary>
        public DelegateCommand AddReportCommand => new DelegateCommand(AddReport);

        public DelegateCommand<Report> UpdateReportCommand => new DelegateCommand<Report>(UpdateReport);

        /// <summary>
        /// Initialize Instance
        /// </summary>
        /// <param name="navigationService"></param>
        /// <param name="referReport"></param>
        public ReportListPageViewModel(INavigationService navigationService, IReferReport referReport)
        {
            _navigationService = navigationService;
            _referReport = referReport;
            Reports = _referReport.Reports.ToReadOnlyReactiveCollection();
        }

        /// <summary>
        /// Navigation ReportPage when create Report.
        /// </summary>
        private void AddReport()
        {
            NavigateReportPage(null);
        }
        /// <summary>
        /// Navigation ReportPage when update Report.
        /// </summary>
        /// <param name="selectedReport"></param>
        private void UpdateReport(Report selectedReport)
        {
            NavigateReportPage(selectedReport.Id);
        }

        /// <summary>
        /// Navigation ReportPage.
        /// </summary>
        private void NavigateReportPage(string reportId)
        {
            var navigationParameter = new NavigationParameters();
            navigationParameter[ReportPageViewModel.ReportIdKey] = reportId;
            _navigationService.NavigateAsync("ReportPage", navigationParameter);
        }

        public void OnNavigatedFrom(NavigationParameters parameters)
        {
        }

        public async void OnNavigatedTo(NavigationParameters parameters)
        {
            await _referReport.SearchAsync();
        }

        public void OnNavigatingTo(NavigationParameters parameters)
        {
        }
    }
}
{'fraction_non_alphanumeric': 0.08980301274623406, 'fraction_numerical': 0.0, 'mean_word_length': 2.4526666666666666, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3109398', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1236, 'n_words': 273}