Example #1
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState)
        {
            IsLoading = true;
            var path = (string)parameter;

            if (path == null)
            {
                path = "home";
            }
            SetTitle(path);
            await LoginUser();

            if (IsLoggedIn)
            {
                if (mode == NavigationMode.New || (mode == NavigationMode.Back && path != _path))
                {
                    _path    = path;
                    Statuses = new TimelineScrollingCollection(Client, path);
                }
                RaisePropertyChanged("Statuses");
            }
            IsLoading = false;
        }
Example #2
0
        public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState)
        {
            IsLoading = true;
            Title     = "";
            await LoginUser();

            var getNewStatus = false;

            // TODO: The navigation cache will make it so that it will always get a new page.
            // I need to figure out a better way to handle this. This is a mess.
            if (IsLoggedIn)
            {
                try
                {
                    if (parameter != null)
                    {
                        var testAccount = JsonConvert.DeserializeObject <Account>((string)parameter);
                        if (Account == null || testAccount.Id != Account.Id)
                        {
                            Account = await Client.GetAccount(testAccount.Id);

                            try
                            {
                                var relationships = await Client.GetAccountRelationships(testAccount.Id);

                                if (relationships.Any())
                                {
                                    Relationship = relationships.FirstOrDefault();
                                }
                            }
                            catch (Exception e)
                            {
                                await MessageDialogMaker.SendMessageDialogAsync(e.Message, false);

                                Relationship = new Relationship();
                            }
                            getNewStatus  = true;
                            IsCurrentUser = false;
                        }
                    }
                    else
                    {
                        var serviceAccountTest = SettingsService.Instance.UserAccount;
                        if (Account == null || serviceAccountTest.Id != Account.Id)
                        {
                            Account = await Client.GetAccount(serviceAccountTest.Id);

                            SettingsService.Instance.UserAccount = Account;
                            getNewStatus  = true;
                            IsCurrentUser = true;
                        }
                    }
                }
                catch (Exception e)
                {
                    // TODO: Show an error if we can't show the user account.
                    await MessageDialogMaker.SendMessageDialogAsync(e.Message, false);

                    Account = SettingsService.Instance.UserAccount;
                }
                Title = Account.UserName;
                if (getNewStatus)
                {
                    Statuses = new TimelineScrollingCollection(Client, "account", Account.Id);
                }
                RaisePropertyChanged("Statuses");
            }
            IsLoading = false;
        }