Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
BootprojectStore opened this issue Mar 17, 2019 · 0 comments
Open

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

BootprojectStore opened this issue Mar 17, 2019 · 0 comments

Comments

@BootprojectStore
Copy link

BootprojectStore commented Mar 17, 2019

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
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant