Beispiel #1
0
        /// <summary>
        /// Sync tasks that are currently in the queue.
        /// </summary>
        /// <exception cref="ApiFormatException">if the request times out.</exception>
        public async Task <bool> Sync()
        {
            var remote = await _client.PullMangaList();

            // First we update from our sync queue.
            while (_queue.Count != 0)
            {
                var m = _queue.Peek();
                // We want to add it and it's not already there
                if (!remote.Contains(m) && m.ListStatus != ApiEntry.ListStatuses.NotInList)
                {
                    await _client.AddManga(m.Id, m.ListStatus);
                }
                await _client.UpdateManga(m); // calls RemoveAnime() implicitly if NotInList

                _queue.Dequeue();             // NOTE: even if it is rejected, it is still being dequeued.
            }
            // Pull again after we have exhausted our sync queue
            _entries = await _client.PullMangaList();

            return(true);
        }