Refactor StatusContent (#39624)
This commit is contained in:
8 files changed
+366
-11
No files matched your search
@@ -15,7 +15,6 @@ import { fetchPoll, vote } from 'mastodon/actions/polls';
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
import { useIdentity } from 'mastodon/identity_context';
|
||||
import type * as Model from 'mastodon/models/poll';
|
||||
import type { Status } from 'mastodon/models/status';
|
||||
import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
||||
|
||||
import { RelativeTimestamp } from './relative_timestamp';
|
||||
@@ -40,12 +39,18 @@ const isPollExpired = (expiresAt: Model.Poll['expires_at']) =>
|
||||
|
||||
interface PollProps {
|
||||
pollId: string;
|
||||
status: Status;
|
||||
accountId: string;
|
||||
statusUrl: string;
|
||||
lang?: string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export const Poll: React.FC<PollProps> = ({ pollId, disabled, status }) => {
|
||||
export const Poll: React.FC<PollProps> = ({
|
||||
pollId,
|
||||
disabled,
|
||||
accountId,
|
||||
statusUrl,
|
||||
}) => {
|
||||
// Third party hooks
|
||||
const poll = useAppSelector((state) => state.polls[pollId]);
|
||||
const identity = useIdentity();
|
||||
@@ -110,14 +115,22 @@ export const Poll: React.FC<PollProps> = ({ pollId, disabled, status }) => {
|
||||
openModal({
|
||||
modalType: 'INTERACTION',
|
||||
modalProps: {
|
||||
accountId,
|
||||
intent: 'vote',
|
||||
accountId: status.getIn(['account', 'id']),
|
||||
url: status.get('uri'),
|
||||
url: statusUrl,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
}, [voteDisabled, dispatch, identity, pollId, selected, status]);
|
||||
}, [
|
||||
voteDisabled,
|
||||
dispatch,
|
||||
identity,
|
||||
pollId,
|
||||
selected,
|
||||
accountId,
|
||||
statusUrl,
|
||||
]);
|
||||
|
||||
const handleReveal = useCallback(() => {
|
||||
setRevealed(true);
|
||||
|
||||
Reference in new issue
Block a user