Example #1
0
        public override async Task ActivateAsync(object parameter, IDictionary <string, object> state, NavigationMode mode)
        {
            var param = parameter as StartPageNavigationParameter;

            if (_migrationService.Check(param.PreviousVersion))
            {
                ExecuteMigrations(param.PreviousVersion);
            }

            Settings.General.AppVersion = _device.AppVersion;

            if (string.IsNullOrEmpty(Settings.Authentication.AccessToken) ||
                string.IsNullOrEmpty(Settings.Authentication.RefreshToken))
            {
                _logging.WriteLine($"Credentials not found. Navigating to the {nameof(Navigation.Pages.LoginPage)}.");
                _navigationService.Navigate(Navigation.Pages.LoginPage);
                _navigationService.ClearHistory();
            }
            else
            {
                if (!param.DatabaseExists)
                {
                    _logging.WriteLine("Database does not exist. Downloading all entries and tags.");
                    await DownloadAllAsync();
                }

                _navigationService.Navigate(Navigation.Pages.MainPage);
                _navigationService.ClearHistory();
            }
        }