<commit_before>﻿namespace SharedLibrary.ViewModels
{
    using Models;
    using Newtonsoft.Json;
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using SharedLibrary.Utils;

    public class YoutubeSearchResultModel
    {
        public YoutubeData Data
        {
            get;
            set;
        }
        public RelayCommand ItemTapped
        {
            get;
            set;
        }
    }

    public class SearchViewModel : BaseViewModel
    {
        private GoogleApis.Search search = null;
        public Action<string> NavigationAction = null;

        public SearchViewModel()
        {
            search = new GoogleApis.Search();
            SearchResults = new ObservableCollection<YoutubeSearchResultModel>();
            ItemTapped = new RelayCommand(ItemTapped_Action);
        }

        private void ItemTapped_Action(object obj)
        {
            YoutubeData data = obj as YoutubeData;
            if (data != null)
            {
                if (NavigationAction != null)
                {
                    NavigationAction(JsonConvert.SerializeObject(data));
                    
                }
            }
        }

        private bool _IsLoading;
        public bool IsLoading
        {
            get
            {
                return _IsLoading;
            }
            set
            {
                SetFieldAndNotify(ref _IsLoading, value);
            }
        }
        private new RelayCommand ItemTapped
        {
            get;
            set;
        }

        public ObservableCollection<YoutubeSearchResultModel> SearchResults
        {
            get;
            private set;
        }

        private string _SearchText;

        public string SearchText
        {
            get { return _SearchText; }
            set { SetFieldAndNotify(ref _SearchText, value); }
        }

        public async Task LoadSearchResult()
        {
            if (string.IsNullOrWhiteSpace(this.SearchText))
            {
                return;
            }
            IsLoading = true; 
            try
            {
                var result = await search.SearchYoutubeVideo(SearchText);
                foreach (var item in result)
                {
                    SearchResults.Add(new YoutubeSearchResultModel()
                    {
                        Data = item,
                        ItemTapped = this.ItemTapped
                    });
                }
            }<commit_msg>Minor changes for clearing list on new searh<commit_after>﻿namespace SharedLibrary.ViewModels
{
    using Models;
    using Newtonsoft.Json;
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using SharedLibrary.Utils;

    public class YoutubeSearchResultModel
    {
        public YoutubeData Data
        {
            get;
            set;
        }
        public RelayCommand ItemTapped
        {
            get;
            set;
        }
    }

    public class SearchViewModel : BaseViewModel
    {
        private GoogleApis.Search search = null;
        public Action<string> NavigationAction = null;

        public SearchViewModel()
        {
            search = new GoogleApis.Search();
            SearchResults = new ObservableCollection<YoutubeSearchResultModel>();
            ItemTapped = new RelayCommand(ItemTapped_Action);
        }

        private void ItemTapped_Action(object obj)
        {
            YoutubeData data = obj as YoutubeData;
            if (data != null)
            {
                if (NavigationAction != null)
                {
                    NavigationAction(JsonConvert.SerializeObject(data));

                }
            }
        }

        private bool _IsLoading;
        public bool IsLoading
        {
            get
            {
                return _IsLoading;
            }
            set
            {
                SetFieldAndNotify(ref _IsLoading, value);
            }
        }
        private new RelayCommand ItemTapped
        {
            get;
            set;
        }

        public ObservableCollection<YoutubeSearchResultModel> SearchResults
        {
            get;
            private set;
        }

        private string _SearchText;

        public string SearchText
        {
            get { return _SearchText; }
            set { SetFieldAndNotify(ref _SearchText, value); }
        }

        public async Task LoadSearchResult()
        {
            if (string.IsNullOrWhiteSpace(this.SearchText))
            {
                return;
            }
            IsLoading = true;
            SearchResults.Clear();
            try
            {
                var result = await search.SearchYoutubeVideo(SearchText);
                foreach (var item in result)
                {
                    SearchResults.Add(new YoutubeSearchResultModel()
                    {
                        Data = item,
                        ItemTapped = this.ItemTapped
                    });
                }
            }
{'fraction_non_alphanumeric': 0.06073258682862023, 'fraction_numerical': 0.0, 'mean_word_length': 1.2283298097251585, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3821807', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1197, 'n_words': 278}