Skip to content

Commit

Permalink
Backwards compatibility for attendee visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
lowercasename committed Feb 5, 2024
1 parent 5c60399 commit 461e271
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/routes/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ router.get("/:eventID", async (req: Request, res: Response) => {
if (el.number && el.number > 1) {
el.name = `${el.name} (${el.number} people)`;
}
return el;
return {
...el,
// Backwards compatibility - if visibility is not set, default to public
visibility: el.visibility || "public",
};
})
.filter((obj, pos, arr) => {
return (
Expand All @@ -159,13 +163,13 @@ router.get("/:eventID", async (req: Request, res: Response) => {
}
return acc;
}, 0) || 0;
const visibleAttendees = event.attendees?.filter(
const visibleAttendees = eventAttendees?.filter(
(attendee) => attendee.visibility === "public",
);
const hiddenAttendees = event.attendees?.filter(
const hiddenAttendees = eventAttendees?.filter(
(attendee) => attendee.visibility === "private",
);
const numberOfHiddenAttendees = event.attendees?.reduce(
const numberOfHiddenAttendees = eventAttendees?.reduce(
(acc, attendee) => {
if (
attendee.status === "attending" &&
Expand Down
12 changes: 7 additions & 5 deletions views/event.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,16 @@
<li{{#if ../editingEnabled}} data-attendee-name="{{this.name}}" data-attendee-id="{{this._id}}"{{/if}}><span class="attendee-name">{{this.name}}</span>{{#if ../editingEnabled}} <a href="#" class="remove-attendee" data-toggle="modal" data-target="#removeAttendeeModal" title="Remove user from event"><i class="fas fa-user-times"></i></a>{{/if}}</li>
{{/each}}
{{#if editingEnabled}}
{{#each visibleAttendees}}
<li{{#if ../editingEnabled}} data-attendee-name="{{this.name}}" data-attendee-id="{{this._id}}"{{/if}}><span class="attendee-name">{{this.name}} (Hidden from public list)</span>{{#if ../editingEnabled}} <a href="#" class="remove-attendee" data-toggle="modal" data-target="#removeAttendeeModal" title="Remove user from event"><i class="fas fa-user-times"></i></a>{{/if}}</li>
{{#each hiddenAttendees}}
<li{{#if ../editingEnabled}} data-attendee-name="{{this.name}}" data-attendee-id="{{this._id}}"{{/if}}><span class="attendee-name">{{this.name}} (hidden from public list)</span>{{#if ../editingEnabled}} <a href="#" class="remove-attendee" data-toggle="modal" data-target="#removeAttendeeModal" title="Remove user from event"><i class="fas fa-user-times"></i></a>{{/if}}</li>
{{/each}}
{{/if}}
</ul>
{{#if numberOfHiddenAttendees}}
<p class="text-center text-muted mb-0">+{{numberOfHiddenAttendees}} hidden attendee{{plural numberOfHiddenAttendees ""}}</p>
{{/if}}
{{#unless editingEnabled}}
{{#if numberOfHiddenAttendees}}
<p class="text-center text-muted mb-0">+{{numberOfHiddenAttendees}} hidden attendee{{plural numberOfHiddenAttendees ""}}</p>
{{/if}}
{{/unless}}
{{else}}
<p class="text-center text-muted mb-0">No attendees yet!</p>
{{/if}}
Expand Down

0 comments on commit 461e271

Please sign in to comment.