protected void SetupStore()
 {
     StatusAndProgressMessageStore.Reset();
     StatusAndProgressMessageStore.StoreMessage(ITEM_ID, "line 1");
     StatusAndProgressMessageStore.StoreMessage(ITEM_ID, "line 2");
     StatusAndProgressMessageStore.StoreMessage(ITEM_ID, "line 3");
 }
        public void FindEpisodesToDownload()
        {
            var controlFile = ApplicationControlFileProvider.GetApplicationConfiguration();

            Logger.Debug(() => $"DownloadViewModel:FindEpisodesToDownload");
            if (controlFile == null)
            {
                Logger.Warning(() => $"DownloadViewModel:FindEpisodesToDownload - no control file");
                return;
            }

            var noItemsText          = ResourceProvider.GetString(Resource.String.no_downloads_text);
            var activeConnectionType = NetworkHelper.ActiveNetworkType;

            Logger.Debug(() => $"DownloadViewModel:FindEpisodesToDownload Active = {activeConnectionType}");
            if (activeConnectionType == INetworkHelper.NetworkType.None)
            {
                noItemsText = ResourceProvider.GetString(Resource.String.no_network_text);
            }
            Observables.SetEmptyText?.Invoke(this, noItemsText);

            lock (SyncLock)
            {
                if (StartedFindingPodcasts)
                {
                    Logger.Warning(() => $"DownloadViewModel:FindEpisodesToDownload - ignoring, already initialised");
                    if (CompletedFindingPodcasts)
                    {
                        Observables.SetSyncItems?.Invoke(this, AllItems);
                        SetTitle();
                    }
                    else
                    {
                        Observables.StartProgress?.Invoke(this, FeedCount);
                    }
                    return;
                }
                StartedFindingPodcasts = true;
                MessageStore.Reset();
            }

            foreach (var item in controlFile.GetPodcasts())
            {
                FeedCount++;
            }

            Observables.StartProgress?.Invoke(this, FeedCount);

            // find the episodes to download
            AllItems.Clear();
            int count = 0;

            foreach (var podcastInfo in controlFile.GetPodcasts())
            {
                var episodesInThisFeed = PodcastEpisodeFinder.FindEpisodesToDownload(
                    controlFile.GetSourceRoot(),
                    controlFile.GetRetryWaitInSeconds(),
                    podcastInfo,
                    controlFile.GetDiagnosticRetainTemporaryFiles());
                foreach (var episode in episodesInThisFeed)
                {
                    var line = $"{episode.Id}, {episode.EpisodeTitle}";
                    Logger.Debug(() => $"DownloadViewModel:FindEpisodesToDownload {line}");
                    MessageStore.StoreMessage(episode.Id, line);
                    var item = new DownloadRecyclerItem()
                    {
                        SyncItem           = episode,
                        ProgressPercentage = 0,
                        Podcast            = podcastInfo,
                        Selected           = true
                    };
                    AllItems.Add(item);
                }
                count++;
                AnalyticsEngine.DownloadFeedEvent(episodesInThisFeed.Count);
                Observables.UpdateProgress?.Invoke(this, count);
            }
            CompletedFindingPodcasts = true;
            Observables.EndProgress?.Invoke(this, null);
            Observables.SetSyncItems?.Invoke(this, AllItems);
            SetTitle();
        }