Skip to content

Commit

Permalink
Consider Eventbrite URLs without event ids incorrect (#21247)
Browse files Browse the repository at this point in the history
* [not verified] Consider URLs without event ids incorrect

* [not verified] Consider URLs without event ids incorrect

* [not verified] Don't wait for testEmbedUrl before validating eventId

* Update fix-eventbrite-urls

Co-authored-by: Samiff <samiff@users.noreply.github.com>
  • Loading branch information
alshakero and samiff authored Oct 1, 2021
1 parent d21dbac commit 4ebba49
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/fix-eventbrite-urls
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: bugfix

Eventbrite Block: consider event URLs without event IDs invalid.
42 changes: 24 additions & 18 deletions projects/plugins/jetpack/extensions/blocks/eventbrite/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,31 @@ export class EventbriteEdit extends Component {
return;
}

const newAttributes = {
eventId: eventIdFromUrl( url ),
url,
};

testEmbedUrl( newAttributes.url, this.setIsResolvingUrl )
.then( resolvedUrl => {
const newValidatedAttributes = getValidatedAttributes( attributeDetails, {
...newAttributes,
url: resolvedUrl,
const eventId = eventIdFromUrl( url );

if ( ! eventId ) {
this.setErrorNotice();
} else {
const newAttributes = {
eventId,
url,
};

testEmbedUrl( newAttributes.url, this.setIsResolvingUrl )
.then( resolvedUrl => {
const newValidatedAttributes = getValidatedAttributes( attributeDetails, {
...newAttributes,
url: resolvedUrl,
} );
setAttributes( newValidatedAttributes );
this.setState( { editedUrl: resolvedUrl } );
noticeOperations.removeAllNotices();
} )
.catch( () => {
setAttributes( { eventId: undefined, url: undefined } );
this.setErrorNotice();
} );
setAttributes( newValidatedAttributes );
this.setState( { editedUrl: resolvedUrl } );
noticeOperations.removeAllNotices();
} )
.catch( () => {
setAttributes( { eventId: undefined, url: undefined } );
this.setErrorNotice();
} );
}
};

setIsResolvingUrl = isResolvingUrl => this.setState( { isResolvingUrl } );
Expand Down

0 comments on commit 4ebba49

Please sign in to comment.