/// <summary>
        /// Retreives the StudyQueue, it contains information such as number of reviews left.
        /// </summary>
        /// <param name="noCache">No cached results if set to true</param>
        /// <returns>StudyQueue</returns>
        public StudyQueue StudyQueue(bool noCache = false)
        {
            if (!noCache && _cachedStudyQueue != null && _cachedTimeStudyQueue > DateTime.Now)
                return _cachedStudyQueue;

            JObject responce = Request("study-queue");
            UpdateUserInformation(responce);

            var requestData = responce["requested_information"];

            _cachedStudyQueue =  JsonConvert.DeserializeObject<StudyQueue>(requestData.ToString());

            _cachedTimeStudyQueue = DateTime.Now.AddMinutes(CacheInMinutes);
            return _cachedStudyQueue;
        }
Example #2
0
        public void RefreshQueue(bool forceUpdate = false)
        {
            UpdateStatus("Getting info...");
            _client.StudyQueue(!forceUpdate).ContinueWith(async (t) => {
                queue = await t;

                // Don't notify repeatedly if the first notification was seen.
                bool showAlert = NextReviewTimeWhenAlertSeen != queue.NextReviewDate;
                bool alertLessons = Properties.Settings.Default.EnableLessonAlerts && queue.LessonsAvailable >= Properties.Settings.Default.MinimumLessons;
                bool alertReviews = Properties.Settings.Default.EnableReviewAlerts && queue.ReviewsAvailable >= Properties.Settings.Default.MinimumReviews;

                if (showAlert && (alertLessons || alertReviews)) {
                    Alert(queue.LessonsAvailable, queue.ReviewsAvailable);
                }
                UpdateStatus(queue.LessonsAvailable, queue.ReviewsAvailable);
            }).ContinueWith((t) => {
                UpdateStatus("Failed to get study queue.");
            }, TaskContinuationOptions.OnlyOnFaulted);
        }