Skip to content

Commit

Permalink
Show account block in Composer
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Sep 3, 2023
1 parent c5766e4 commit a9109f4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
33 changes: 21 additions & 12 deletions src/components/account-block.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import './account-block.css';

import { useNavigate } from 'react-router-dom';

// import { useNavigate } from 'react-router-dom';
import enhanceContent from '../utils/enhance-content';
import niceDateTime from '../utils/nice-date-time';
import shortenNumber from '../utils/shorten-number';
Expand All @@ -21,6 +20,8 @@ function AccountBlock({
onClick,
showActivity = false,
showStats = false,
accountInstance,
hideDisplayName = false,
}) {
if (skeleton) {
return (
Expand All @@ -35,7 +36,7 @@ function AccountBlock({
);
}

const navigate = useNavigate();
// const navigate = useNavigate();

const {
id,
Expand All @@ -53,7 +54,10 @@ function AccountBlock({
note,
group,
} = account;
const [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
let [_, acct1, acct2] = acct.match(/([^@]+)(@.+)/i) || [, acct];
if (accountInstance) {
acct2 = `@${accountInstance}`;
}

const verifiedField = fields?.find((f) => !!f.verifiedAt && !!f.value);

Expand All @@ -68,7 +72,8 @@ function AccountBlock({
e.preventDefault();
if (onClick) return onClick(e);
if (internal) {
navigate(`/${instance}/a/${id}`);
// navigate(`/${instance}/a/${id}`);
location.hash = `/${instance}/a/${id}`;
} else {
states.showAccount = {
account,
Expand All @@ -79,14 +84,18 @@ function AccountBlock({
>
<Avatar url={avatar} size={avatarSize} squircle={bot} />
<span>
{displayName ? (
<b>
<EmojiText text={displayName} emojis={emojis} />
</b>
) : (
<b>{username}</b>
{!hideDisplayName && (
<>
{displayName ? (
<b>
<EmojiText text={displayName} emojis={emojis} />
</b>
) : (
<b>{username}</b>
)}
<br />
</>
)}
<br />
<span class="account-block-acct">
@{acct1}
<wbr />
Expand Down
9 changes: 9 additions & 0 deletions src/components/compose.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
position: sticky;
top: 0;
z-index: 100;
white-space: nowrap;
}
#compose-container .compose-top .account-block {
text-align: start;
pointer-events: none;
overflow: hidden;
color: var(--text-insignificant-color);
line-height: 1.1;
font-size: 90%;
}

#compose-container textarea {
Expand Down
18 changes: 12 additions & 6 deletions src/components/compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import supports from '../utils/supports';
import useInterval from '../utils/useInterval';
import visibilityIconsMap from '../utils/visibility-icons-map';

import Avatar from './avatar';
import AccountBlock from './account-block';
// import Avatar from './avatar';
import Icon from './icon';
import Loader from './loader';
import Modal from './modal';
Expand Down Expand Up @@ -508,11 +509,16 @@ function Compose({
<div id="compose-container" class={standalone ? 'standalone' : ''}>
<div class="compose-top">
{currentAccountInfo?.avatarStatic && (
<Avatar
url={currentAccountInfo.avatarStatic}
size="xl"
alt={currentAccountInfo.username}
squircle={currentAccountInfo?.bot}
// <Avatar
// url={currentAccountInfo.avatarStatic}
// size="xl"
// alt={currentAccountInfo.username}
// squircle={currentAccountInfo?.bot}
// />
<AccountBlock
account={currentAccountInfo}
accountInstance={currentAccount.instanceURL}
hideDisplayName
/>
)}
{!standalone ? (
Expand Down

0 comments on commit a9109f4

Please sign in to comment.