public static void RemoveQuestionsAndSave(IList <string> keysToDelete) { // Remove from questions-list and add to read-questions-list. foreach (string key in keysToDelete) { if (questionsCollection.Remove(key)) { ReadListManager.AddReadQuestion(key); } else { // Removing a question that was not in the questions-list. Debugger.Break(); } } // Only save if at least one question was deleted. if (keysToDelete.Count > 0) { ReadListManager.LimitTo450AndSave(); // Do not wait until questions-save is completed. var saveOperation = QuestionsManager.SaveAsync(); // And refresh tile and badge. FeedManager.UpdateTileAndBadge(); } }
// Notice that tile update, badge update and saveing only occurs if at least one questions is removed. public static IAsyncAction RemoveReadQuestionsUpdateTileAndBadgeAndSaveAsync() { return(AsyncInfo.Run(async(cancellationToken) => { uint removedQuestions = await RemoveQuestionsInReadList(); // Only save if at least one question was deleted. if (removedQuestions > 0) { await QuestionsManager.SaveAsync(); FeedManager.UpdateTileAndBadge(); } })); }
public static IAsyncOperation <AddQuestionsResult> QueryTagAsync(string websiteUrl, string tagEncoded) { return(AsyncInfo.Run(async(cancellationToken) => { // Retrieve questions, skip the LatestPubDate validation and add all questions. AddQuestionsResult result = await FeedManager.QuerySingleWebsiteAsync(websiteUrl, tagEncoded, true); // Only limit and save questions if list changed. if (result.AddedQuestions > 0 || result.UpdatedQuestions > 0) { uint removedQuestions = await QuestionsManager.RemoveQuestionsInReadList(); await QuestionsManager.LimitTo150AndSaveAsync(); FeedManager.UpdateTileAndBadge(); } return result; })); }