Skip to content

Commit

Permalink
FIX: handles when current user didnt set attendance yet
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaffeux committed Apr 29, 2020
1 parent 6bcce74 commit 0181b14
Showing 1 changed file with 9 additions and 6 deletions.
Expand Up @@ -13,30 +13,33 @@ export default createWidget("discourse-post-event-status", {
},

defaultState(attrs) {
const status = attrs.watchingInvitee ? attrs.watchingInvitee.status : null;

return {
onChange: data => {
this.state.icon = null;
this.state.label = data.label;
this.state.options.headerClass = "disabled";
this.sendWidgetAction("changeWatchingInviteeStatus", data.id);
},
icon: this._headerIconForStatus(attrs.watchingInvitee.status),
icon: this._headerIconForStatus(status),
options: {
caret: true,
headerClass: ""
},
label: attrs.watchingInvitee.status
? `discourse_post_event.models.invitee.status.${attrs.watchingInvitee.status}`
label: status
? `discourse_post_event.models.invitee.status.${status}`
: "discourse_post_event.models.invitee.status.unknown",
statuses: this._statusesForStatus(attrs.watchingInvitee.status)
statuses: this._statusesForStatus(status)
};
},

transform(attrs) {
return {
mightAttend:
attrs.watchingInvitee.status === "going" ||
attrs.watchingInvitee.status === "interested"
attrs.status &&
(attrs.watchingInvitee.status === "going" ||
attrs.watchingInvitee.status === "interested")
};
},

Expand Down

0 comments on commit 0181b14

Please sign in to comment.