Exemplo n.º 1
0
        public async Task Setup()
        {
            await DBTestHelpers.DeleteDB();

            MRUSettingsCache.ResetCache();
            MRUListUpdateStream.Reset();
        }
Exemplo n.º 2
0
        public async Task UpdateMachineMRUWithNoChangeRemoteMRUList()
        {
            // If something happens that causes an update to a remote MRU, we should
            // not generate a change to the rest of the world.

            // Write out an MRU list to a machine, and start up everything.
            GenerateOtherMachineMRU("MACHINE2", 10);

            int count = 0;

            MRUListUpdateStream.GetMRUListStream()
            .Subscribe(_ => count++);

            await TestUtils.SpinWaitAreEqual(1, () => count);

            // Now, redo the update for machine 2, so we write the same data back.
            // Wait, and see what happens.
            var mrus = MRUSettingsCache.GetFromMachine("MACHINE2");

            MRUSettingsCache.UpdateForMachine("MACHINE2", mrus);

            await TestUtils.SpinWait(() => count != 1, 500, false);

            Assert.AreEqual(1, count);

            // Write it to a new machine
            MRUSettingsCache.UpdateForMachine("MACHINE1", mrus);
            await TestUtils.SpinWait(() => count != 1, 500, false);

            Assert.AreEqual(1, count);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Return the MRU list that is first off the presses.
        /// </summary>
        /// <returns></returns>
        private static async Task <IWalker.MRU[]> GetFirstMRUList(int sizeMin = 0)
        {
            var s = MRUListUpdateStream.GetMRUListStream();

            IWalker.MRU[] dummyCache = null;
            using (var tmp = s.Subscribe(lst => dummyCache = lst))
            {
                await TestUtils.SpinWait(() => dummyCache != null, 1000);

                await TestUtils.SpinWait(() => dummyCache.Length >= sizeMin, 1000);
            }

            return(dummyCache);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Setup the page
        /// </summary>
        public StartPageViewModel(IScreen screen)
        {
            HostScreen = screen;

            // A Open URL Control View
            OpenURLControlVM = new OpenURLControlViewModel(screen);

            // MRU button was pressed.
            OpenMRUMeeting = ReactiveCommand.Create();
            OpenMRUMeeting
            .Cast <MRU>()
            .Select(mru => ConvertToIMeeting(mru))
            .Subscribe(addr => HostScreen.Router.Navigate.Execute(new MeetingPageViewModel(HostScreen, addr)));

            // And an upcoming meeting was pushed...
            OpenUpcomingMeeting = ReactiveCommand.Create();
            OpenUpcomingMeeting
            .Cast <IMeetingRefExtended>()
            .Where(m => m != null)
            .Subscribe(m => HostScreen.Router.Navigate.Execute(new MeetingPageViewModel(HostScreen, m.Meeting)));

            // And populate the most recently viewed meeting list.
            RecentMeetings = new ReactiveList <MRU>();

            MRUListUpdateStream.GetMRUListStream()
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(l => SetMRUMeetings(l));

            // Upcoming meetings. This is easy - we fetch once.
            // But since they are coming from multiple sources, we have to be a little
            // careful about combining them.
            UpcomingMeetings       = new ReactiveList <IMeetingRefExtended>();
            UpdateUpcomingMeetings = ReactiveCommand.Create();
            var meetingList = from xup in UpdateUpcomingMeetings
                              from category in CategoryDB.LoadCategories()
                              from meetings in (category.DisplayOnHomePage ? category.MeetingList.FetchAndUpdateRecentMeetings(false).OnErrorResumeNext(Observable.Empty <IMeetingRefExtended[]>()) : Observable.Return(new IMeetingRefExtended[0]))
                              select Tuple.Create(category.MeetingList, meetings);

            meetingList
            .Select(ml => {
                _meetingCatalog[ml.Item1.UniqueString] = ml.Item2;
                return(_meetingCatalog);
            })
            .Select(mc => mc.SelectMany(mi => mi.Value).Where(mi => mi.StartTime.Within(TimeSpan.FromDays(Settings.DaysOfUpcomingMeetingsToShowOnMainPage))).OrderByDescending(minfo => minfo.StartTime).ToArray())
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(meetings => SetUpcomingMeetings(meetings));

            UpdateUpcomingMeetings.Execute(null);
        }