Skip to content

Commit

Permalink
Add missing user null checks, Fixes #26 (beta 14)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkwinkelmann committed Nov 24, 2020
1 parent 868a35b commit 8bcd271
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/dist/forum.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/forum.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/src/forum/addDiscussionComposerItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default () => {

// Add button to DiscussionComposer header
extend(DiscussionComposer.prototype, 'headerItems', function (items) {
if (app.session.user.canStartPolls()) {
if (app.session.user && app.session.user.canStartPolls()) {
items.add(
'polls',
<a className="DiscussionComposer-poll" onclick={this.addPoll.bind(this)}>
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/addDiscussionControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default () => {
const poll = discussion.poll();
const user = app.session.user;

if (!(poll && ((user && user.canEditPolls()) || (post.user().canSelfEditPolls() && post.user().id() === user.id())) && post.number() === 1)) {
if (!(poll && ((user && user.canEditPolls()) || (post.user() && post.user().canSelfEditPolls() && post.user().id() === user.id())) && post.number() === 1)) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions js/src/forum/addPollToDiscussion.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default () => {
channels.main.bind('newPollVote', (data) => {
var userId = parseInt(data['user_id']);

if (userId == app.session.user.id()) return;
if (app.session.user && userId == app.session.user.id()) return;

let poll = app.store.getById('polls', this.attrs.post.discussion().poll().id());

Expand All @@ -41,7 +41,7 @@ export default () => {
let newVotes = poll.votes();

newVotes.some((vote, i) => {
if (parseInt(vote.user().id()) === userId) {
if (parseInt(vote.user() && vote.user().id()) === userId) {
newVotes.splice(i, 1);
}
});
Expand Down

0 comments on commit 8bcd271

Please sign in to comment.