<commit_before>namespace DotNetRu.Clients.UI.Pages.Home
{
    using System;

    using DotNetRu.Clients.Portable.Model;
    using DotNetRu.Clients.Portable.ViewModel;
    using DotNetRu.Utils.Helpers;

    using FormsToolkit;

    using Xamarin.Forms;

    public partial class NewsPage
    {
        private NewsViewModel newsViewModel;

        public NewsPage()
        {
            this.InitializeComponent();
            this.BindingContext = new NewsViewModel();

            if (Device.RuntimePlatform == Device.UWP)
            {
                this.ToolbarItems.Add(
                    new ToolbarItem
                        {
                            Text = "Refresh",
                            Icon = "toolbar_refresh.png",
                            Command = this.NewsViewModel.RefreshCommand
                        });
            }
            this.ListViewSocial.ItemSelected += (sender, e) => this.ListViewSocial.SelectedItem = null;
        }

        public override AppPage PageType => AppPage.News;

        public NewsViewModel NewsViewModel => this.newsViewModel ?? (this.newsViewModel = this.BindingContext as NewsViewModel);

        protected override void OnAppearing()
        {
            base.OnAppearing();

            this.UpdatePage();
        }

        protected override void OnDisappearing()
        {
            base.OnDisappearing();
            MessagingService.Current.Unsubscribe<string>(MessageKeys.NavigateToImage);
        }

        private void UpdatePage()
        {
            bool forceRefresh = DateTime.UtcNow > (this.NewsViewModel?.NextForceRefresh ?? DateTime.UtcNow);

            this.newsViewModel.EvaluateVisualState();

            if (forceRefresh)<commit_msg>Fix #269: open tweets from News form #273<commit_after>using Xamarin.Essentials;

namespace DotNetRu.Clients.UI.Pages.Home
{
    using System;

    using DotNetRu.Clients.Portable.Model;
    using DotNetRu.Clients.Portable.ViewModel;
    using DotNetRu.Utils.Helpers;

    using FormsToolkit;

    using Xamarin.Forms;

    public partial class NewsPage
    {
        private NewsViewModel newsViewModel;

        public NewsPage()
        {
            this.InitializeComponent();
            this.BindingContext = new NewsViewModel();

            if (Device.RuntimePlatform == Device.UWP)
            {
                this.ToolbarItems.Add(
                    new ToolbarItem
                        {
                            Text = "Refresh",
                            Icon = "toolbar_refresh.png",
                            Command = this.NewsViewModel.RefreshCommand
                        });
            }
            this.ListViewSocial.ItemSelected += async (sender, e) =>
            {
                if (e.SelectedItem is Tweet tweet && !string.IsNullOrWhiteSpace(tweet.Url))
                {
                    await Launcher.OpenAsync(new Uri(tweet.Url));
                }
                this.ListViewSocial.SelectedItem = null;
            };
        }

        public override AppPage PageType => AppPage.News;

        public NewsViewModel NewsViewModel => this.newsViewModel ?? (this.newsViewModel = this.BindingContext as NewsViewModel);

        protected override void OnAppearing()
        {
            base.OnAppearing();

            this.UpdatePage();
        }

        protected override void OnDisappearing()
        {
            base.OnDisappearing();
            MessagingService.Current.Unsubscribe<string>(MessageKeys.NavigateToImage);
        }

        private void UpdatePage()
        {
            bool forceRefresh = DateTime.UtcNow > (this.NewsViewModel?.NextForceRefresh ?? DateTime.UtcNow);

            this.newsViewModel.EvaluateVisualState();

            if (forceRefresh)
{'fraction_non_alphanumeric': 0.0830238726790451, 'fraction_numerical': 0.0015915119363395225, 'mean_word_length': 1.6897289586305277, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2753246', 'n_tokens_mistral': 988, 'n_tokens_neox': 897, 'n_words': 178}