Skip to content

Commit

Permalink
Merge pull request #89 from froboy/event-series-description-fix
Browse files Browse the repository at this point in the history
fix: DS-1240 Fix recurring event description
  • Loading branch information
podarok authored Dec 5, 2023
2 parents ade596e + aabd23a commit 91291a8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
2 changes: 1 addition & 1 deletion js/gated-content/dist/gated-content.umd.min.js

Large diffs are not rendered by default.

30 changes: 20 additions & 10 deletions js/gated-content/src/views/LiveStreamPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,26 @@ export default {
: this.video.attributes.media;
},
descriptionProcessed() {
// Check description is not empty.
if (this.description.length > 0) {
// Handle D9 description fields.
if (typeof this.description === 'string') {
return this.description ? this.description.processed : '';
}
// Handle D10 description fields.
if (typeof this.description === 'object') {
return this.description ? this.description[0].processed : '';
}
// Handle D9 description fields.
if (typeof this.description === 'string') {
return this.description ? this.description.processed : '';
}
/*
D10 fields behave differently in a few situations...
For an event with no overrides, this.description will be an array of objects. We need
to get the first instance of this.description[].processed, but calling array indexes
directly (this.description[0]) could fail without checks.
*/
if (Array.isArray(this.description) && this.description.length > 0) {
// Find the first object in this.description that has a `processed` key.
return this.description.find((e) => 'processed' in e).processed;
}
/*
For an event instance that overrides the series, this.description will be a single object,
so we can reference the processed text directly.
*/
if (typeof this.description.processed === 'string') {
return this.description.processed;
}
return '';
},
Expand Down
30 changes: 20 additions & 10 deletions js/gated-content/src/views/VirtualMeetingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,26 @@ export default {
return link;
},
descriptionProcessed() {
// Check description is not empty.
if (this.description.length > 0) {
// Handle D9 description fields.
if (typeof this.description === 'string') {
return this.description ? this.description.processed : '';
}
// Handle D10 description fields.
if (typeof this.description === 'object') {
return this.description ? this.description[0].processed : '';
}
// Handle D9 description fields.
if (typeof this.description === 'string') {
return this.description ? this.description.processed : '';
}
/*
D10 fields behave differently in a few situations...
For an event with no overrides, this.description will be an array of objects. We need
to get the first instance of this.description[].processed, but calling array indexes
directly (this.description[0]) could fail without checks.
*/
if (Array.isArray(this.description) && this.description.length > 0) {
// Find the first object in this.description that has a `processed` key.
return this.description.find((e) => 'processed' in e).processed;
}
/*
For an event instance that overrides the series, this.description will be a single object,
so we can reference the processed text directly.
*/
if (typeof this.description.processed === 'string') {
return this.description.processed;
}
return '';
},
Expand Down

0 comments on commit 91291a8

Please sign in to comment.