Пример #1
0
        async Task <bool> ExecuteLoadSessionsAsync(bool force = false)
        {
            if (IsBusy)
            {
                return(false);
            }

            try
            {
                NextForceRefresh = DateTime.UtcNow.AddMinutes(45);
                IsBusy           = true;
                NoSessionsFound  = false;
                Filter           = string.Empty;

                #if DEBUG
                await Task.Delay(1000);
                #endif

                Sessions.ReplaceRange(await StoreManager.SessionStore.GetItemsAsync(force));

                SessionsFiltered.ReplaceRange(Sessions);
                SortSessions();

                if (SessionsGrouped.Count == 0)
                {
                    if (Settings.Current.FavoritesOnly)
                    {
                        if (!Settings.Current.ShowPastSessions)
                        {
                            NoSessionsFoundMessage = "You haven't favorited\nany sessions yet.";
                        }
                        else
                        {
                            NoSessionsFoundMessage = "No Sessions Found";
                        }
                    }
                    else
                    {
                        NoSessionsFoundMessage = "No Sessions Found";
                    }

                    NoSessionsFound = true;
                }
                else
                {
                    NoSessionsFound = false;
                }
            }
            catch (Exception ex)
            {
                Logger.Report(ex, "Method", "ExecuteLoadSessionsAsync");
                MessagingService.Current.SendMessage(MessageKeys.Error, ex);
            }
            finally
            {
                IsBusy = false;
            }

            return(true);
        }
Пример #2
0
        async Task ExecuteFilterSessionsAsync()
        {
            IsBusy          = true;
            NoSessionsFound = false;

            // Abort the current command if the user is typing fast
            if (!string.IsNullOrEmpty(Filter))
            {
                var query = Filter;
                await Task.Delay(250);

                if (query != Filter)
                {
                    return;
                }
            }

            SessionsFiltered.ReplaceRange(Sessions.Search(Filter));
            SortSessions();

            if (SessionsGrouped.Count == 0)
            {
                NoSessionsFoundMessage = "No Sessions Found";
                NoSessionsFound        = true;
            }
            else
            {
                NoSessionsFound = false;
            }

            IsBusy = false;
        }
Пример #3
0
        async Task <bool> ExecuteLoadSessionsAsync(bool force = false)
        {
            if (IsBusy)
            {
                return(false);
            }

            try
            {
                NextForceRefresh = DateTime.UtcNow.AddMinutes(45);
                IsBusy           = true;
                NoSessionsFound  = false;
                Filter           = string.Empty;

                Sessions.ReplaceRange((await StoreManager.SessionStore.GetItemsAsync(force)).ToSessionCellViews(SessionCellViewModelFactory));

                SessionsFiltered.ReplaceRange(Sessions.Search());
                SortSessions();

                if (SessionsGrouped.Count == 0)
                {
                    if (Settings.FavoritesOnly)
                    {
                        if (!Settings.ShowPastSessions)
                        {
                            NoSessionsFoundMessage = "You haven't favorited\nany sessions yet.";
                        }
                        else
                        {
                            NoSessionsFoundMessage = "No Sessions Found";
                        }
                    }
                    else
                    {
                        NoSessionsFoundMessage = "No Sessions Found";
                    }

                    NoSessionsFound = true;
                }
                else
                {
                    NoSessionsFound = false;
                }
            }
            catch (Exception ex)
            {
                Logger.Log($"{ex.Message}, Method, ExecuteLoadSessionsAsync", Prism.Logging.Category.Exception, Priority.High);
                EventAggregator.GetEvent <ErrorEvent>().Publish(ex);
            }
            finally
            {
                IsBusy = false;
            }

            return(true);
        }
Пример #4
0
        async Task ExecuteFilterSessionsAsync()
        {
            IsBusy          = true;
            NoSessionsFound = false;

            // Abort the current command if the query has changed and is not empty
            if (!string.IsNullOrEmpty(Filter))
            {
                var query = Filter;
                await Task.Delay(250);

                if (query != Filter)
                {
                    return;
                }
            }

            SessionsFiltered.ReplaceRange(Sessions.Search(Filter));
            SortSessions();

            if (SessionsGrouped.Count == 0)
            {
                if (Settings.Current.FavoritesOnly)
                {
                    if (!Settings.Current.ShowPastSessions && !string.IsNullOrWhiteSpace(Filter))
                    {
                        NoSessionsFoundMessage = "You haven't favorited\nany sessions yet.";
                    }
                    else
                    {
                        NoSessionsFoundMessage = "No Sessions Found";
                    }
                }
                else
                {
                    NoSessionsFoundMessage = "No Sessions Found";
                }

                NoSessionsFound = true;
            }
            else
            {
                NoSessionsFound = false;
            }

            IsBusy = false;
        }
Пример #5
0
 void SortSessions()
 {
     SessionsGrouped.ReplaceRange(SessionsFiltered.FilterAndGroupByDate());
 }
Пример #6
0
        async Task <bool> ExecuteLoadSessionsAsync(bool force = false)
        {
            if (IsBusy)
            {
                return(false);
            }

            try
            {
                NextForceRefresh = DateTime.UtcNow.AddMinutes(45);
                IsBusy           = true;
                NoSessionsFound  = false;
                Filter           = string.Empty;

                #if DEBUG
                await Task.Delay(1000);
                #endif

                Sessions.ReplaceRange(await StoreManager.SessionStore.GetItemsAsync(force));

                SessionsFiltered.ReplaceRange(Sessions);
                SortSessions();

                if (SessionsGrouped.Count == 0)
                {
                    if (Settings.Current.FavoritesOnly)
                    {
                        if (!Settings.Current.ShowPastSessions)
                        {
                            NoSessionsFoundMessage = "You haven't favorited\nany sessions yet.";
                        }
                        else
                        {
                            NoSessionsFoundMessage = "No Sessions Found";
                        }
                    }
                    else
                    {
                        NoSessionsFoundMessage = "No Sessions Found";
                    }

                    NoSessionsFound = true;
                }
                else
                {
                    NoSessionsFound = false;
                }

                if (Device.OS != TargetPlatform.WinPhone && Device.OS != TargetPlatform.Windows && FeatureFlags.AppLinksEnabled)
                {
                    foreach (var session in Sessions)
                    {
                        try
                        {
                            // data migration: older applinks are removed so the index is rebuilt again
                            Application.Current.AppLinks.DeregisterLink(new Uri($"http://{AboutThisApp.AppLinksBaseDomain}/{AboutThisApp.SessionsSiteSubdirectory}/{session.Id}"));

                            Application.Current.AppLinks.RegisterLink(session.GetAppLink());
                        }
                        catch (Exception applinkException)
                        {
                            // don't crash the app
                            Logger.Report(applinkException, "AppLinks.RegisterLink", session.Id);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Report(ex, "Method", "ExecuteLoadSessionsAsync");
                MessagingService.Current.SendMessage(MessageKeys.Error, ex);
            }
            finally
            {
                IsBusy = false;
            }

            return(true);
        }