public static async Task PullBookmarkFromUserFavoriteAsync(bool forectRefresh = false, bool forceSyncFromCloud = false)
        {
            if (BookmarkList == null)
            {
                await LoadBookmarkDataAsync();
            }
            if (User != null)
            {
                // guard about login data
                return;

                await User.SyncFavoriteListAsync(forectRefresh);

                var  favList = from fav in User.FavoriteList orderby fav.VolumeId group fav by fav.SeriesTitle;
                bool Changed = false;

                if (forceSyncFromCloud)
                {
                    for (int i = 0; i < BookmarkList.Count; i++)
                    {
                        var bk = BookmarkList[i];
                        if (!favList.Any(g => g.First().SeriesTitle == bk.SeriesTitle))
                        {
                            BookmarkList.RemoveAt(i--);
                            Changed = true;
                        }
                    }
                }

                foreach (var series in favList)
                {
                    var vol = series.LastOrDefault();
                    if (BookmarkList.Any(bk => bk.SeriesTitle == vol.SeriesTitle))
                    {
                        continue;
                    }
                    var item = new BookmarkInfo {
                        SeriesTitle = vol.SeriesTitle, VolumeTitle = vol.VolumeTitle, ViewDate = vol.FavTime
                    };
                    item.Position = new NovelPositionIdentifier { /*SeriesId = volume.ParentSeriesId,*/
                        VolumeId = vol.VolumeId, VolumeNo = -1
                    };
                    BookmarkList.Add(item);
                    Changed = true;
                }
                if (Changed)
                {
                    await SaveBookmarkDataAsync();
                }
            }
        }
Esempio n. 2
0
        // Methods
        // =======

        /// <summary>
        /// Add a bookmark to the bookmarks list. Used to lighten the methods
        /// using such an operation.
        /// </summary>
        /// <param name="newBookmark">Bookmark to be added></param>
        public void AddBookmark(Bookmark newBookmark)
        {
            BookmarkList.Add(newBookmark);
        }