FIX: Redirect to homepage if no posts exist (#14951)

After permanently deleting the first post of a topic the user was
sometimes stuck on the page because of an infinite loop. This problem
happened more often in Firefox.
This commit is contained in:
Bianca Nenciu 2021-11-16 11:10:07 +02:00 committed by GitHub
parent c2be7c65e8
commit 88523a6d6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -189,7 +189,8 @@ export default createWidget("post-stream", {
const posts = attrs.posts || [];
const postArray = posts.toArray();
const postArrayLength = postArray.length;
const maxPostNumber = postArray[postArrayLength - 1].post_number;
const maxPostNumber =
postArrayLength > 0 ? postArray[postArrayLength - 1].post_number : 0;
const result = [];
const before = attrs.gaps && attrs.gaps.before ? attrs.gaps.before : {};
const after = attrs.gaps && attrs.gaps.after ? attrs.gaps.after : {};