public void FetchCurrentBlogAdditionalDataAsync() { if (null == CurrentBlog) { throw new ArgumentException("CurrentBlog may not be null", "CurrentBlog"); } GetPostFormatsRPC rpc = new GetPostFormatsRPC(CurrentBlog); CurrentBlog.showLoadingIndicator(); rpc.Completed += OnFetchPostFormatsRPCCompleted; rpc.ExecuteAsync(); }
public bool FetchCurrentBlogPostsAsync(bool more) { if (null == CurrentBlog) { throw new ArgumentException("CurrentBlog may not be null", "CurrentBlog"); } //we're already downloading data here--don't allow scenarios where we could be //kicking off another download if (_trackedBlogs.Contains(CurrentBlog)) { return(false); } CurrentBlog.showLoadingIndicator(); int numerberOfPosts = 0; if (more) { numerberOfPosts = Math.Max(CurrentBlog.PostListItems.Count, CHUNK_SIZE); if (CurrentBlog.HasOlderPosts) { numerberOfPosts += CHUNK_SIZE; } else { //removing this block you will enable the refresh of posts when reached the end of the list and no more posts are available CurrentBlog.hideLoadingIndicator(); return(false); } } else { numerberOfPosts = CHUNK_SIZE; } GetRecentPostsRPC rpc = new GetRecentPostsRPC(CurrentBlog); rpc.NumberOfPosts = numerberOfPosts; rpc.Completed += OnFetchCurrentBlogPostsCompleted; CurrentBlog.IsLoadingPosts = true; rpc.ExecuteAsync(); return(true); }
public void UpdateParametersForCaching() { if (VaryByBlog) { var sublayoutWrapper = Parent as Sublayout; if (sublayoutWrapper != null) { SiteContext site = Sitecore.Context.Site; if (sublayoutWrapper.Cacheable && site != null && site.CacheHtml && CurrentBlog != null) { var key = "CacheVaryByBlogKey=" + CurrentBlog.SafeGet(x => x.ID).SafeGet(x => x.ToShortID()).SafeGet(x => x.ToString()); sublayoutWrapper.Parameters += (string.IsNullOrEmpty(sublayoutWrapper.Parameters)) ? string.Empty : "&" + key; } } } }
private void OnFetchOptionsRPCCompleted(object sender, XMLRPCCompletedEventArgs <Option> args) { GetOptionsRPC rpc = sender as GetOptionsRPC; rpc.Completed -= OnFetchOptionsRPCCompleted; CurrentBlog.hideLoadingIndicator(); if (null == args.Error) { CurrentBlog.Options.Clear(); args.Items.ForEach(option => { CurrentBlog.Options.Add(option); }); NotifyFetchComplete(); //Notify here the end of the synch } else { NotifyExceptionOccurred(new ExceptionEventArgs(args.Error)); } }
private void OnFetchCurrentBlogPostsCompleted(object sender, XMLRPCCompletedEventArgs <PostListItem> args) { CurrentBlog.hideLoadingIndicator(); CurrentBlog.IsLoadingPosts = false; GetRecentPostsRPC rpc = sender as GetRecentPostsRPC; rpc.Completed -= OnFetchCurrentBlogPostsCompleted; if (null == args.Error) { int prevPostsCount = CurrentBlog.PostListItems.Count; CurrentBlog.PostListItems.Clear(); // If we asked for more and we got what we had, there are no more posts to load if (rpc.NumberOfPosts > CHUNK_SIZE && (args.Items.Count <= prevPostsCount)) { CurrentBlog.HasOlderPosts = false; } else if (rpc.NumberOfPosts == CHUNK_SIZE) { //we should reset the flag otherwise when you refresh this blog you can't get more than CHUNK_SIZE posts CurrentBlog.HasOlderPosts = true; } foreach (PostListItem item in args.Items) { CurrentBlog.PostListItems.Add(item); } CurrentBlog.addLocalPostDraftsToPostList(); NotifyFetchComplete(); } else { NotifyExceptionOccurred(new ExceptionEventArgs(args.Error)); } }
public void EditBlog() { if (CurrentBlog == null) { return; } CurrentBlog.BeginEdit(); var blogSettings = blogSettingsCreator(); blogSettings.InitializeBlog(CurrentBlog); var result = _windowManager.ShowDialog(blogSettings); if (result != true) { CurrentBlog.CancelEdit(); return; } CurrentBlog.EndEdit(); }
private void OnFetchCurrentBlogCommentsCompleted(object sender, XMLRPCCompletedEventArgs <Comment> args) { GetAllCommentsRPC rpc = sender as GetAllCommentsRPC; rpc.Completed -= OnFetchCurrentBlogCommentsCompleted; CurrentBlog.IsLoadingComments = false; if (null == args.Error) { int prevCommentsCount = CurrentBlog.Comments.Count; CurrentBlog.Comments.Clear(); // If we asked for more and we got what we had, there are no more posts to load if (rpc.Number > CHUNK_SIZE && (args.Items.Count <= prevCommentsCount)) { CurrentBlog.HasOlderComments = false; } else if (rpc.Number == CHUNK_SIZE) { //we should reset the flag otherwise when you refresh this blog you can't get more than CHUNK_SIZE comments CurrentBlog.HasOlderComments = true; } foreach (Comment comment in args.Items) { CurrentBlog.Comments.Add(comment); } NotifyFetchComplete(); } else { NotifyExceptionOccurred(new ExceptionEventArgs(args.Error)); } CurrentBlog.hideLoadingIndicator(); }