Skip to content

Commit

Permalink
FIX: prevents error if post event node is not found (#626)
Browse files Browse the repository at this point in the history
This could happen during a server error for example. Ideally we should ensure the post event doesn't disappear on such error, but at least for now we avoid the crash.
  • Loading branch information
jjaffeux authored Oct 23, 2024
1 parent d31933b commit 72a28c4
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,18 @@ function initializeDiscoursePostEventDecorator(api) {
return;
}

const div = document.createElement("div");
cooked.querySelector(".discourse-post-event").before(div);
const postEventNode = cooked.querySelector(".discourse-post-event");

if (!postEventNode) {
return;
}

const wrapper = document.createElement("div");
postEventNode.before(wrapper);

const event = DiscoursePostEventEvent.create(post.event);

helper.renderGlimmer(div, <template>
helper.renderGlimmer(wrapper, <template>
<DiscoursePostEvent @event={{event}} />
</template>);
}
Expand Down

0 comments on commit 72a28c4

Please sign in to comment.