sforkowany z mirror/soapbox
Merge remote-tracking branch 'origin/develop' into chats
commit
dc6ac50c70
|
@ -59,7 +59,7 @@ const StatusMedia: React.FC<IStatusMedia> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const openMedia = (media: ImmutableList<Attachment>, index: number) => {
|
const openMedia = (media: ImmutableList<Attachment>, index: number) => {
|
||||||
dispatch(openModal('MEDIA', { media, index }));
|
dispatch(openModal('MEDIA', { media, status, index }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const openVideo = (media: Attachment, time: number): void => {
|
const openVideo = (media: Attachment, time: number): void => {
|
||||||
|
|
|
@ -117,9 +117,9 @@ const Status: React.FC<IStatus> = (props) => {
|
||||||
|
|
||||||
if (firstAttachment) {
|
if (firstAttachment) {
|
||||||
if (firstAttachment.type === 'video') {
|
if (firstAttachment.type === 'video') {
|
||||||
dispatch(openModal('VIDEO', { media: firstAttachment, time: 0 }));
|
dispatch(openModal('VIDEO', { status, media: firstAttachment, time: 0 }));
|
||||||
} else {
|
} else {
|
||||||
dispatch(openModal('MEDIA', { media: status.media_attachments, index: 0 }));
|
dispatch(openModal('MEDIA', { status, media: status.media_attachments, index: 0 }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,7 +27,7 @@ const ReportStatus: React.FC<IReportStatus> = ({ status }) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const handleOpenMedia = (media: Attachment, index: number) => {
|
const handleOpenMedia = (media: Attachment, index: number) => {
|
||||||
dispatch(openModal('MEDIA', { media, index }));
|
dispatch(openModal('MEDIA', { media, status, index }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteStatus = () => {
|
const handleDeleteStatus = () => {
|
||||||
|
|
|
@ -228,7 +228,7 @@ const Thread: React.FC<IThread> = (props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOpenMedia = (media: ImmutableList<AttachmentEntity>, index: number) => {
|
const handleOpenMedia = (media: ImmutableList<AttachmentEntity>, index: number) => {
|
||||||
dispatch(openModal('MEDIA', { media, index }));
|
dispatch(openModal('MEDIA', { media, status, index }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOpenVideo = (media: ImmutableList<AttachmentEntity>, time: number) => {
|
const handleOpenVideo = (media: ImmutableList<AttachmentEntity>, time: number) => {
|
||||||
|
|
|
@ -23,7 +23,7 @@ const messages = defineMessages({
|
||||||
|
|
||||||
interface IMediaModal {
|
interface IMediaModal {
|
||||||
media: ImmutableList<Attachment>,
|
media: ImmutableList<Attachment>,
|
||||||
status: Status,
|
status?: Status,
|
||||||
account: Account,
|
account: Account,
|
||||||
index: number,
|
index: number,
|
||||||
time?: number,
|
time?: number,
|
||||||
|
@ -96,17 +96,17 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
|
||||||
const handleStatusClick: React.MouseEventHandler = e => {
|
const handleStatusClick: React.MouseEventHandler = e => {
|
||||||
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
history.push(`/@${account.acct}/posts/${status.id}`);
|
history.push(`/@${account.acct}/posts/${status?.id}`);
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCloserClick: React.MouseEventHandler = ({ currentTarget }) => {
|
const handleCloserClick: React.MouseEventHandler = ({ target }) => {
|
||||||
const whitelist = ['zoomable-image'];
|
const whitelist = ['zoomable-image'];
|
||||||
const activeSlide = document.querySelector('.media-modal .react-swipeable-view-container > div[aria-hidden="false"]');
|
const activeSlide = document.querySelector('.media-modal .react-swipeable-view-container > div[aria-hidden="false"]');
|
||||||
|
|
||||||
const isClickOutside = currentTarget === activeSlide || !activeSlide?.contains(currentTarget);
|
const isClickOutside = target === activeSlide || !activeSlide?.contains(target as Element);
|
||||||
const isWhitelisted = whitelist.some(w => currentTarget.classList.contains(w));
|
const isWhitelisted = whitelist.some(w => (target as Element).classList.contains(w));
|
||||||
|
|
||||||
if (isClickOutside || isWhitelisted) {
|
if (isClickOutside || isWhitelisted) {
|
||||||
onClose();
|
onClose();
|
||||||
|
@ -209,7 +209,7 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
|
||||||
<Audio
|
<Audio
|
||||||
src={attachment.url}
|
src={attachment.url}
|
||||||
alt={attachment.description}
|
alt={attachment.description}
|
||||||
poster={attachment.preview_url !== attachment.url ? attachment.preview_url : (status.getIn(['account', 'avatar_static'])) as string | undefined}
|
poster={attachment.preview_url !== attachment.url ? attachment.preview_url : (status?.getIn(['account', 'avatar_static'])) as string | undefined}
|
||||||
backgroundColor={attachment.meta.getIn(['colors', 'background']) as string | undefined}
|
backgroundColor={attachment.meta.getIn(['colors', 'background']) as string | undefined}
|
||||||
foregroundColor={attachment.meta.getIn(['colors', 'foreground']) as string | undefined}
|
foregroundColor={attachment.meta.getIn(['colors', 'foreground']) as string | undefined}
|
||||||
accentColor={attachment.meta.getIn(['colors', 'accent']) as string | undefined}
|
accentColor={attachment.meta.getIn(['colors', 'accent']) as string | undefined}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useHistory, useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import snackbar from 'soapbox/actions/snackbar';
|
import snackbar from 'soapbox/actions/snackbar';
|
||||||
import { confirmEmailVerification } from 'soapbox/actions/verification';
|
import { confirmEmailVerification } from 'soapbox/actions/verification';
|
||||||
import { Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
|
import { Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
|
||||||
import { useAppDispatch } from 'soapbox/hooks';
|
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||||
|
|
||||||
|
import { ChallengeTypes } from './index';
|
||||||
|
|
||||||
import type { AxiosError } from 'axios';
|
import type { AxiosError } from 'axios';
|
||||||
|
|
||||||
|
@ -30,6 +32,14 @@ const messages = defineMessages({
|
||||||
|
|
||||||
const Success = () => {
|
const Success = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
const history = useHistory();
|
||||||
|
const currentChallenge = useAppSelector((state) => state.verification.currentChallenge as ChallengeTypes);
|
||||||
|
|
||||||
|
// Bypass the user straight to the next step.
|
||||||
|
if (currentChallenge === ChallengeTypes.SMS) {
|
||||||
|
history.push('/verify');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack space={4} alignItems='center'>
|
<Stack space={4} alignItems='center'>
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { useDispatch } from 'react-redux';
|
|
||||||
import { Redirect } from 'react-router-dom';
|
import { Redirect } from 'react-router-dom';
|
||||||
|
|
||||||
import { fetchVerificationConfig } from 'soapbox/actions/verification';
|
import { fetchVerificationConfig } from 'soapbox/actions/verification';
|
||||||
import { useAppSelector } from 'soapbox/hooks';
|
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||||
|
|
||||||
import Registration from './registration';
|
import Registration from './registration';
|
||||||
import AgeVerification from './steps/age-verification';
|
import AgeVerification from './steps/age-verification';
|
||||||
import EmailVerification from './steps/email-verification';
|
import EmailVerification from './steps/email-verification';
|
||||||
import SmsVerification from './steps/sms-verification';
|
import SmsVerification from './steps/sms-verification';
|
||||||
|
|
||||||
enum ChallengeTypes {
|
export enum ChallengeTypes {
|
||||||
EMAIL = 'email',
|
EMAIL = 'email',
|
||||||
SMS = 'sms',
|
SMS = 'sms',
|
||||||
AGE = 'age',
|
AGE = 'age',
|
||||||
|
@ -23,7 +22,7 @@ const verificationSteps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const Verification = () => {
|
const Verification = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const isInstanceReady = useAppSelector((state) => state.verification.instance.get('isReady') === true);
|
const isInstanceReady = useAppSelector((state) => state.verification.instance.get('isReady') === true);
|
||||||
const isRegistrationOpen = useAppSelector(state => state.verification.instance.get('registrations') === true);
|
const isRegistrationOpen = useAppSelector(state => state.verification.instance.get('registrations') === true);
|
||||||
|
|
Ładowanie…
Reference in New Issue