Skip to content

Commit d361a69

Browse files
authored
fix missing @ in Follow-Me block (#898)
1 parent a0c1d56 commit d361a69

File tree

11 files changed

+16
-18
lines changed

11 files changed

+16
-18
lines changed

build/follow-me/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'f33252a2026002ddb56c');
1+
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '1ec66c1edf3d9b0b6678');

build/follow-me/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/follow-me/view.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'ab8c0dad126bb0a61ed6');
1+
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'bc272e3d4aaa7992f4c7');

build/follow-me/view.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/remote-reply/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'ab787305c7ed07812b96');
1+
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '45f08e094782c24c4c34');

build/remote-reply/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/reply/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '9eb1d863fcf6d209ef29');
1+
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '808c98599517db815fc5');

build/reply/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/class-blocks.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ public static function render_follow_me_block( $attrs ) {
152152
array( 'icon', 'name', 'webfinger' )
153153
);
154154

155-
// add `@` prefix if it's missing
156-
if ( '@' !== substr( $attrs['profileData']['webfinger'], 0, 1 ) ) {
157-
$attrs['profileData']['webfinger'] = '@' . $attrs['profileData']['webfinger'];
158-
}
159-
160155
$wrapper_attributes = get_block_wrapper_attributes(
161156
array(
162157
'aria-label' => __( 'Follow me on the Fediverse', 'activitypub' ),

src/follow-me/follow-me.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ function fetchProfile( userId ) {
3333
}
3434

3535
function Profile( { profile, popupStyles, userId } ) {
36-
const { avatar, name, webfinger } = profile;
36+
const { webfinger, avatar, name } = profile;
37+
// check if webfinger starts with @ and add it if it doesn't
38+
const webfingerWithAt = webfinger.startsWith( '@' ) ? webfinger : `@${ webfinger }`;
3739
return (
3840
<div className="activitypub-profile">
3941
<img className="activitypub-profile__avatar" src={ avatar } alt={ name } />
4042
<div className="activitypub-profile__content">
4143
<div className="activitypub-profile__name">{ name }</div>
42-
<div className="activitypub-profile__handle" title={ webfinger }>{ webfinger }</div>
44+
<div className="activitypub-profile__handle" title={ webfingerWithAt }>{ webfingerWithAt }</div>
4345
</div>
4446
<Follow profile={ profile } popupStyles={ popupStyles } userId={ userId } />
4547
</div>
@@ -74,11 +76,12 @@ function DialogFollow( { profile, userId } ) {
7476
const actionText = __( 'Follow', 'activitypub' );
7577
const resourceUrl = `/${ namespace }/actors/${userId}/remote-follow?resource=`;
7678
const copyDescription = __( 'Copy and paste my profile into the search field of your favorite fediverse app or server.', 'activitypub' );
79+
const webfingerWithAt = webfinger.startsWith( '@' ) ? webfinger : `@${ webfinger }`;
7780

7881
return <Dialog
7982
actionText={ actionText }
8083
copyDescription={ copyDescription }
81-
handle={ webfinger }
84+
handle={ webfingerWithAt }
8285
resourceUrl={ resourceUrl }
8386
/>;
8487
}

0 commit comments

Comments
 (0)