Merge branch 'nostr' into 'develop'
Truncate Nostr pubkeys in reply mentions See merge request soapbox-pub/soapbox!2328
This commit is contained in:
commit
a8b0dc93f2
4 changed files with 18 additions and 4 deletions
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- Posts: truncate Nostr pubkeys in reply mentions.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Posts: fixed emojis being cut off in reactions modal.
|
- Posts: fixed emojis being cut off in reactions modal.
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { openModal } from 'soapbox/actions/modals';
|
||||||
import HoverRefWrapper from 'soapbox/components/hover-ref-wrapper';
|
import HoverRefWrapper from 'soapbox/components/hover-ref-wrapper';
|
||||||
import HoverStatusWrapper from 'soapbox/components/hover-status-wrapper';
|
import HoverStatusWrapper from 'soapbox/components/hover-status-wrapper';
|
||||||
import { useAppDispatch } from 'soapbox/hooks';
|
import { useAppDispatch } from 'soapbox/hooks';
|
||||||
|
import { isPubkey } from 'soapbox/utils/nostr';
|
||||||
|
|
||||||
import type { Account, Status } from 'soapbox/types/entities';
|
import type { Account, Status } from 'soapbox/types/entities';
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ const StatusReplyMentions: React.FC<IStatusReplyMentions> = ({ status, hoverable
|
||||||
className='reply-mentions__account'
|
className='reply-mentions__account'
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
@{account.username}
|
@{isPubkey(account.username) ? account.username.slice(0, 8) : account.username}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { openModal } from 'soapbox/actions/modals';
|
||||||
import { useAppSelector, useCompose, useFeatures } from 'soapbox/hooks';
|
import { useAppSelector, useCompose, useFeatures } from 'soapbox/hooks';
|
||||||
import { statusToMentionsAccountIdsArray } from 'soapbox/reducers/compose';
|
import { statusToMentionsAccountIdsArray } from 'soapbox/reducers/compose';
|
||||||
import { makeGetStatus } from 'soapbox/selectors';
|
import { makeGetStatus } from 'soapbox/selectors';
|
||||||
|
import { isPubkey } from 'soapbox/utils/nostr';
|
||||||
|
|
||||||
import type { Status as StatusEntity } from 'soapbox/types/entities';
|
import type { Status as StatusEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
|
@ -52,9 +53,14 @@ const ReplyMentions: React.FC<IReplyMentions> = ({ composeId }) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const accounts = to.slice(0, 2).map((acct: string) => (
|
const accounts = to.slice(0, 2).map((acct: string) => {
|
||||||
<span className='reply-mentions__account'>@{acct.split('@')[0]}</span>
|
const username = acct.split('@')[0];
|
||||||
)).toArray();
|
return (
|
||||||
|
<span className='reply-mentions__account'>
|
||||||
|
@{isPubkey(username) ? username.slice(0, 8) : username}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}).toArray();
|
||||||
|
|
||||||
if (to.size > 2) {
|
if (to.size > 2) {
|
||||||
accounts.push(
|
accounts.push(
|
||||||
|
|
6
app/soapbox/utils/nostr.ts
Normal file
6
app/soapbox/utils/nostr.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/** Check whether the given input is a valid Nostr hexidecimal pubkey. */
|
||||||
|
const isPubkey = (value: string) => /^[0-9a-f]{64}$/i.test(value);
|
||||||
|
|
||||||
|
export {
|
||||||
|
isPubkey,
|
||||||
|
};
|
Loading…
Reference in a new issue