Skip to content

All post is not loaded on startup [Fix] #257

Description

@BootprojectStore

This was a strange behaviour, so I discovered that all post is not loaded correctly on startup.
So I added a fix for this to wait for the posts to finish.

To recreate the issue: Start application and add a new post. Restart the application, the new post is not shown or not all posts exists in list.
Result: List does not contain all posts.
Expected result: All items in list is shown.
File: BlogController.cs

 public async Task<IActionResult> Index([FromRoute]int page = 0){
            var posts = await _blog.GetPosts(_settings.Value.PostsPerPage, _settings.Value.PostsPerPage * page);
            var result = Task.FromResult(posts).Result; //<----- Wait for the posts to finish

            ViewData["Title"] = _manifest.Name;
            ViewData["Description"] = _manifest.Description;
            ViewData["prev"] = $"/{page + 1}/";
            ViewData["next"] = $"/{(page <= 1 ? null : page - 1 + "/")}";
            return View("~/Views/Blog/Index.cshtml", result);  //<----- result
        }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions