Skip to content

Commit

Permalink
FIX: Redirect to homepage if no posts exist (#14951)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nbianca committed Nov 16, 2021
1 parent c2be7c6 commit 88523a6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/assets/javascripts/discourse/app/widgets/post-stream.js
Expand Up @@ -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 : {};
Expand Down

0 comments on commit 88523a6

Please sign in to comment.