private async void LoadSection(ProfileContentType type)
        {
            items.Clear();
            page = 0;

            Profile profile = await api.GetProfileAsync(username, type);

            if (firstLoad)
            {
                Score     = profile.Score;
                Rants     = profile.RantsCount;
                Upvoted   = profile.UpvotedCount;
                Comments  = profile.CommentsCount;
                Viewed    = profile.ViewedCount;
                Favorites = profile.FavoritesCount;

                if (profile.AvatarImage != null)
                {
                    Avatar = api.GetAvatar(profile.AvatarImage);
                }

                firstLoad = false;
            }

            AddItems(profile);

            if (items.Count > 0)
            {
                window.ItemsListBox.ScrollIntoView(items[0]);
            }
        }
Esempio n. 2
0
        private async void RunChecker(int version)
        {
            try
            {
                while (true)
                {
                    if (!IsLatest(version))
                    {
                        break;
                    }

                    AppManager.Instance.RemoveReadUpdates();

                    long lastTime = ds.FollowedUsersLastChecked;

                    List <ViewModels.Rant> added = new List <ViewModels.Rant>();

                    var users = ds.FollowedUsers.ToList(); //Can be modified while checking

                    foreach (string user in users)
                    {
                        Profile profile = await api.GetProfileAsync(user, ProfileContentType.Rants);

                        AddTo(lastTime, user, ProfileContentType.Rants, profile.Rants, added);

                        profile = await api.GetProfileAsync(user, ProfileContentType.Upvoted);

                        AddTo(lastTime, user, ProfileContentType.Upvoted, profile.Rants, added);
                    }

                    if (!IsLatest(version))
                    {
                        break;
                    }

                    if (added.Count > 0)
                    {
                        long latest = added.Max(x => x.RawCreateTime);

                        foreach (var r in added)
                        {
                            AppManager.Instance.AddUpdate(r);
                        }

                        ds.FollowedUsersLastChecked = latest;
                    }

                    SendUpdate(UpdateType.UpdatesCheck, added.Count);

                    int millis = ds.FollowedUsersUpdateInterval * 60 * 1000;
                    Thread.Sleep(millis);
                }
            }
            catch (Exception ex)
            {
                SendUpdate(UpdateType.Error, error: ex);
            }
        }
Esempio n. 3
0
        public async Task <Dtos.Profile> GetProfile()
        {
            var profile = await api.GetProfileAsync("allanx2000");

            return(profile);
        }