2024-08-06 21:51:45 +02:00
|
|
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
2024-06-12 17:38:22 +02:00
|
|
|
import { useLocation, useParams } from 'react-router-dom';
|
2024-10-15 13:10:47 +02:00
|
|
|
import { Trans, useTranslation } from 'react-i18next';
|
2025-03-06 13:15:33 +01:00
|
|
|
import { setAccount, useAccount } from '@plebbit/plebbit-react-hooks';
|
|
|
|
|
import useSubplebbitsStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits';
|
|
|
|
|
import useSubplebbitsPagesStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits-pages';
|
2025-05-12 23:54:44 +02:00
|
|
|
import Plebbit from '@plebbit/plebbit-js';
|
2024-08-27 18:46:42 +02:00
|
|
|
import { formatMarkdown } from '../../lib/utils/post-utils';
|
2024-06-08 21:33:56 +02:00
|
|
|
import { getFormattedTimeAgo } from '../../lib/utils/time-utils';
|
2024-04-28 20:08:41 +02:00
|
|
|
import { isValidURL } from '../../lib/utils/url-utils';
|
2024-06-12 17:38:22 +02:00
|
|
|
import { isAllView, isSubscriptionsView } from '../../lib/utils/view-utils';
|
2024-06-26 18:20:25 +02:00
|
|
|
import useSelectedTextStore from '../../stores/use-selected-text-store';
|
2024-08-06 21:57:28 +02:00
|
|
|
import usePublishReply from '../../hooks/use-publish-reply';
|
2024-05-29 16:17:37 +02:00
|
|
|
import useIsMobile from '../../hooks/use-is-mobile';
|
2024-04-28 20:08:41 +02:00
|
|
|
import styles from './reply-modal.module.css';
|
2024-05-31 15:45:48 +02:00
|
|
|
import { LinkTypePreviewer } from '../post-form';
|
2024-04-28 20:08:41 +02:00
|
|
|
import _ from 'lodash';
|
2024-08-06 20:12:07 +02:00
|
|
|
import useAnonMode from '../../hooks/use-anon-mode';
|
2024-11-04 17:34:40 +01:00
|
|
|
import FileUploader from '../../plugins/file-uploader';
|
|
|
|
|
import { Capacitor } from '@capacitor/core';
|
2025-03-01 11:48:56 +01:00
|
|
|
import { useSpring, animated } from '@react-spring/web';
|
|
|
|
|
import { useDrag } from '@use-gesture/react';
|
2024-11-04 17:34:40 +01:00
|
|
|
|
|
|
|
|
const isAndroid = Capacitor.getPlatform() === 'android';
|
2024-04-28 20:08:41 +02:00
|
|
|
|
|
|
|
|
interface ReplyModalProps {
|
|
|
|
|
closeModal: () => void;
|
2024-08-09 12:08:22 +02:00
|
|
|
showReplyModal: boolean;
|
2024-04-28 20:08:41 +02:00
|
|
|
parentCid: string;
|
2024-08-06 20:12:07 +02:00
|
|
|
postCid: string;
|
2024-04-30 11:08:01 +02:00
|
|
|
scrollY: number;
|
2024-08-14 10:23:47 +02:00
|
|
|
subplebbitAddress: string;
|
2024-04-28 20:08:41 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-14 10:23:47 +02:00
|
|
|
const ReplyModal = ({ closeModal, showReplyModal, parentCid, postCid, scrollY, subplebbitAddress }: ReplyModalProps) => {
|
2024-04-28 20:08:41 +02:00
|
|
|
const { t } = useTranslation();
|
2024-11-07 13:51:39 +01:00
|
|
|
const { setPublishReplyOptions, publishReply, resetPublishReplyOptions, replyIndex } = usePublishReply({
|
|
|
|
|
cid: parentCid,
|
|
|
|
|
subplebbitAddress,
|
|
|
|
|
postCid,
|
|
|
|
|
});
|
2024-04-28 20:08:41 +02:00
|
|
|
const account = useAccount();
|
|
|
|
|
const { displayName } = account?.author || {};
|
2024-05-31 15:45:48 +02:00
|
|
|
const [url, setUrl] = useState('');
|
2024-06-26 18:20:25 +02:00
|
|
|
const textRef = useRef<HTMLTextAreaElement | null>(null);
|
2024-04-28 20:08:41 +02:00
|
|
|
const urlRef = useRef<HTMLInputElement>(null);
|
2024-06-26 18:20:25 +02:00
|
|
|
const { selectedText } = useSelectedTextStore();
|
2024-04-28 20:08:41 +02:00
|
|
|
|
2024-08-06 20:12:07 +02:00
|
|
|
const { anonMode, getNewSigner, getExistingSigner } = useAnonMode(postCid);
|
2025-03-06 13:15:33 +01:00
|
|
|
const comment = useSubplebbitsPagesStore((state) => state.comments[postCid]);
|
2024-08-06 20:12:07 +02:00
|
|
|
const address = comment?.author?.address;
|
|
|
|
|
|
2024-08-06 21:51:45 +02:00
|
|
|
const getAnonAddressForReply = useCallback(async () => {
|
2025-01-29 13:09:38 +01:00
|
|
|
const existingSigner = await getExistingSigner(address);
|
|
|
|
|
if (existingSigner) {
|
|
|
|
|
setPublishReplyOptions({
|
|
|
|
|
signer: existingSigner,
|
|
|
|
|
author: {
|
|
|
|
|
address: existingSigner.address,
|
|
|
|
|
displayName: displayName || undefined,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
const newSigner = await getNewSigner();
|
|
|
|
|
if (newSigner) {
|
2024-08-08 17:48:45 +02:00
|
|
|
setPublishReplyOptions({
|
2025-01-29 13:09:38 +01:00
|
|
|
signer: newSigner,
|
2024-08-08 17:48:45 +02:00
|
|
|
author: {
|
2025-01-29 13:09:38 +01:00
|
|
|
address: newSigner.address,
|
2024-08-25 18:58:38 +02:00
|
|
|
displayName: displayName || undefined,
|
2024-08-08 17:48:45 +02:00
|
|
|
},
|
|
|
|
|
});
|
2024-08-06 20:12:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
2025-01-29 13:09:38 +01:00
|
|
|
}, [address, getExistingSigner, getNewSigner, setPublishReplyOptions, displayName]);
|
2024-08-06 20:12:07 +02:00
|
|
|
|
2024-11-04 17:55:51 +01:00
|
|
|
const [error, setError] = useState<string | null>(null);
|
2025-01-31 23:38:07 +01:00
|
|
|
const [lengthError, setLengthError] = useState<string | null>(null);
|
|
|
|
|
|
|
|
|
|
const checkContentLength = useRef(
|
|
|
|
|
_.debounce((content: string, t: Function) => {
|
|
|
|
|
const length = content.trim().length;
|
|
|
|
|
if (length > 2000) {
|
|
|
|
|
setError(null);
|
|
|
|
|
setLengthError(`${t('error')}: ${t('comment_field_too_long', { length })}`);
|
|
|
|
|
} else {
|
|
|
|
|
setLengthError(null);
|
|
|
|
|
}
|
|
|
|
|
}, 1000),
|
|
|
|
|
).current;
|
2024-11-04 17:55:51 +01:00
|
|
|
|
2024-08-21 11:11:19 +02:00
|
|
|
const onPublishReply = () => {
|
2024-08-29 17:48:34 +02:00
|
|
|
const currentContent = textRef.current?.value.slice(contentPrefix.length).trim() || '';
|
|
|
|
|
const currentUrl = urlRef.current?.value.trim() || '';
|
2024-04-28 20:08:41 +02:00
|
|
|
|
2024-08-29 17:48:34 +02:00
|
|
|
if (!currentContent && !currentUrl) {
|
2025-01-31 23:38:07 +01:00
|
|
|
setError(t('error') + ': ' + t('empty_comment_alert'));
|
2024-04-28 20:08:41 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentUrl && !isValidURL(currentUrl)) {
|
2025-01-31 23:38:07 +01:00
|
|
|
setError(t('error') + ': ' + t('invalid_url_alert'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkContentLength.cancel();
|
|
|
|
|
setLengthError(null);
|
|
|
|
|
|
|
|
|
|
if (currentContent.length > 2000) {
|
|
|
|
|
setError(t('error') + ': ' + t('field_too_long'));
|
2024-04-28 20:08:41 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2024-08-06 20:12:07 +02:00
|
|
|
|
2024-11-04 17:55:51 +01:00
|
|
|
setError(null);
|
2024-08-06 21:51:45 +02:00
|
|
|
publishReply();
|
2024-04-28 20:08:41 +02:00
|
|
|
};
|
|
|
|
|
|
2024-08-25 18:58:38 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (anonMode) {
|
2025-01-29 13:09:38 +01:00
|
|
|
setPublishReplyOptions({
|
|
|
|
|
signer: undefined,
|
|
|
|
|
author: {
|
|
|
|
|
address: undefined,
|
|
|
|
|
displayName: displayName || undefined,
|
|
|
|
|
},
|
|
|
|
|
});
|
2024-08-25 18:58:38 +02:00
|
|
|
getAnonAddressForReply();
|
2025-01-29 13:09:38 +01:00
|
|
|
} else {
|
|
|
|
|
setPublishReplyOptions({
|
|
|
|
|
signer: undefined,
|
|
|
|
|
author: {
|
|
|
|
|
...account?.author,
|
|
|
|
|
displayName: displayName || account?.author?.displayName,
|
|
|
|
|
},
|
|
|
|
|
});
|
2024-08-25 18:58:38 +02:00
|
|
|
}
|
2025-01-29 13:09:38 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
}, [anonMode]);
|
2024-08-25 18:58:38 +02:00
|
|
|
|
2024-08-21 11:11:19 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (typeof replyIndex === 'number') {
|
|
|
|
|
resetPublishReplyOptions();
|
|
|
|
|
closeModal();
|
|
|
|
|
}
|
|
|
|
|
}, [replyIndex, resetPublishReplyOptions, closeModal]);
|
|
|
|
|
|
2024-04-29 13:28:04 +02:00
|
|
|
const nodeRef = useRef<HTMLDivElement>(null);
|
2024-05-29 16:17:37 +02:00
|
|
|
const isMobile = useIsMobile();
|
2024-04-28 20:08:41 +02:00
|
|
|
|
2025-03-02 16:04:45 +01:00
|
|
|
const [{ x, y }, api] = useSpring(() => ({
|
|
|
|
|
x: window.innerWidth / 2 - 150,
|
2025-03-05 12:01:48 +01:00
|
|
|
y: window.innerHeight / 2 - 200,
|
2025-03-02 16:04:45 +01:00
|
|
|
}));
|
2025-03-01 11:48:56 +01:00
|
|
|
|
|
|
|
|
const bind = useDrag(
|
2025-03-03 22:27:39 +01:00
|
|
|
({ active, event, offset: [ox, oy] }) => {
|
|
|
|
|
if (active) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
document.body.style.userSelect = 'none';
|
|
|
|
|
document.body.style.webkitUserSelect = 'none';
|
|
|
|
|
} else {
|
|
|
|
|
document.body.style.userSelect = '';
|
|
|
|
|
document.body.style.webkitUserSelect = '';
|
|
|
|
|
}
|
2025-03-01 11:48:56 +01:00
|
|
|
api.start({ x: ox, y: oy, immediate: true });
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
from: () => [x.get(), y.get()],
|
|
|
|
|
filterTaps: true,
|
2025-03-02 16:04:45 +01:00
|
|
|
bounds: undefined,
|
2025-03-01 11:48:56 +01:00
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
2024-04-29 13:28:04 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (nodeRef.current && isMobile) {
|
|
|
|
|
const viewportHeight = window.innerHeight;
|
2025-03-02 16:04:45 +01:00
|
|
|
const centeredPosition = scrollY + viewportHeight / 2 - 300;
|
2025-03-01 11:48:56 +01:00
|
|
|
api.start({ y: centeredPosition, immediate: true });
|
2024-04-29 13:28:04 +02:00
|
|
|
}
|
2025-03-01 11:48:56 +01:00
|
|
|
}, [isMobile, scrollY, api]);
|
2024-04-29 13:28:04 +02:00
|
|
|
|
2024-05-09 22:55:57 +02:00
|
|
|
const parentCidRef = useRef<HTMLSpanElement>(null);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (parentCidRef.current && parentCidRef.current) {
|
|
|
|
|
const cidWidth = parentCidRef.current.offsetWidth;
|
|
|
|
|
parentCidRef.current.style.width = `${cidWidth}px`;
|
|
|
|
|
}
|
|
|
|
|
}, [parentCid]);
|
|
|
|
|
|
2024-06-12 17:38:22 +02:00
|
|
|
const location = useLocation();
|
2024-10-29 17:40:09 +01:00
|
|
|
const isInAllView = isAllView(location.pathname);
|
2024-06-17 12:17:36 +02:00
|
|
|
const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
|
2025-03-06 13:15:33 +01:00
|
|
|
const subplebbit = useSubplebbitsStore((state) => state.subplebbits[subplebbitAddress]);
|
2024-06-08 21:33:56 +02:00
|
|
|
const { updatedAt } = subplebbit || {};
|
|
|
|
|
const isBoardOffline = subplebbit?.updatedAt && subplebbit.updatedAt < Date.now() / 1000 - 60 * 60;
|
|
|
|
|
const offlineAlert = updatedAt
|
|
|
|
|
? isBoardOffline && (
|
2024-10-15 13:10:47 +02:00
|
|
|
<div className={styles.offlineBoard}>
|
2025-01-31 23:06:50 +01:00
|
|
|
{t('warning')}: <Trans i18nKey='posts_last_synced_info' values={{ time: getFormattedTimeAgo(updatedAt) }} />
|
2024-10-15 13:10:47 +02:00
|
|
|
</div>
|
2024-06-08 21:33:56 +02:00
|
|
|
)
|
2024-10-15 13:10:47 +02:00
|
|
|
: t('subplebbit_offline_info');
|
2024-06-08 21:33:56 +02:00
|
|
|
|
2024-08-09 12:08:22 +02:00
|
|
|
useEffect(() => {
|
2025-03-07 19:16:40 +01:00
|
|
|
if (showReplyModal && !isMobile) {
|
2024-08-09 12:08:22 +02:00
|
|
|
setTimeout(() => {
|
|
|
|
|
if (textRef.current) {
|
|
|
|
|
textRef.current.focus();
|
|
|
|
|
}
|
|
|
|
|
}, 0);
|
2025-01-30 22:05:05 +01:00
|
|
|
|
|
|
|
|
const handleEscape = (e: KeyboardEvent) => {
|
|
|
|
|
if (e.key === 'Escape') {
|
|
|
|
|
closeModal();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
document.addEventListener('keydown', handleEscape);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
document.removeEventListener('keydown', handleEscape);
|
|
|
|
|
};
|
2024-06-26 18:20:25 +02:00
|
|
|
}
|
2025-03-07 19:16:40 +01:00
|
|
|
}, [showReplyModal, closeModal, isMobile]);
|
2024-06-26 18:20:25 +02:00
|
|
|
|
2024-07-22 12:29:05 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (textRef.current) {
|
|
|
|
|
const len = textRef.current.value.length;
|
|
|
|
|
textRef.current.setSelectionRange(len, len);
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
|
|
|
|
|
2025-11-08 21:19:36 +01:00
|
|
|
const contentPrefix = `>>${parentCid && Plebbit.getShortCid(parentCid)}\n`;
|
2024-06-26 22:20:45 +02:00
|
|
|
|
2024-12-21 00:38:15 +01:00
|
|
|
// enable spellcheck after the prefix is set
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (showReplyModal && textRef.current) {
|
|
|
|
|
textRef.current.spellcheck = false;
|
|
|
|
|
textRef.current.value = contentPrefix + (selectedText || '');
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (textRef.current) {
|
|
|
|
|
textRef.current.spellcheck = true;
|
|
|
|
|
}
|
|
|
|
|
}, 100);
|
|
|
|
|
}
|
|
|
|
|
}, [showReplyModal, contentPrefix, selectedText]);
|
|
|
|
|
|
2024-06-26 22:20:45 +02:00
|
|
|
const handleContentInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
|
|
|
const { value } = e.target;
|
|
|
|
|
if (!value.startsWith(contentPrefix)) {
|
|
|
|
|
e.target.value = contentPrefix + value.slice(contentPrefix.length);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleContentChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
2024-08-26 13:52:00 +02:00
|
|
|
const contentWithoutPrefix = e.target.value.slice(contentPrefix.length);
|
2024-08-27 18:46:42 +02:00
|
|
|
const formattedContent = formatMarkdown(contentWithoutPrefix);
|
|
|
|
|
if (textRef.current && textRef.current.value !== formattedContent) {
|
|
|
|
|
setPublishReplyOptions({ content: formattedContent });
|
2025-01-31 23:38:07 +01:00
|
|
|
checkContentLength(formattedContent, t);
|
2024-06-26 22:20:45 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-04 17:34:40 +01:00
|
|
|
// on android, auto upload file to image hosting sites with open api
|
|
|
|
|
const [isUploading, setIsUploading] = useState(false);
|
|
|
|
|
const [uploadedFileName, setUploadedFileName] = useState<string | null>(null);
|
|
|
|
|
const handleUpload = async () => {
|
|
|
|
|
try {
|
|
|
|
|
setIsUploading(true);
|
|
|
|
|
const result = await FileUploader.pickAndUploadMedia();
|
|
|
|
|
console.log('Upload result:', result);
|
|
|
|
|
if (result.url) {
|
|
|
|
|
setUrl(result.url);
|
|
|
|
|
if (urlRef.current) {
|
|
|
|
|
urlRef.current.value = result.url;
|
|
|
|
|
}
|
|
|
|
|
setPublishReplyOptions({ link: result.url || undefined });
|
|
|
|
|
if (result.fileName) {
|
|
|
|
|
setUploadedFileName(result.fileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2024-11-04 17:55:51 +01:00
|
|
|
console.error('Upload failed, ', error);
|
2024-11-04 17:34:40 +01:00
|
|
|
if (error instanceof Error && error.message !== 'File selection cancelled') {
|
2024-11-04 17:55:51 +01:00
|
|
|
setError(`${t('upload_failed')}, ${error.message}`);
|
2024-11-04 17:34:40 +01:00
|
|
|
} else if (typeof error === 'string' && error !== 'File selection cancelled') {
|
2024-11-04 17:55:51 +01:00
|
|
|
setError(`${t('upload_failed')}, ${error}`);
|
2024-11-04 17:34:40 +01:00
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
setIsUploading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-26 22:25:56 +01:00
|
|
|
const hasInitializedDisplayName = useRef(false);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (displayName && !hasInitializedDisplayName.current) {
|
|
|
|
|
hasInitializedDisplayName.current = true;
|
|
|
|
|
setPublishReplyOptions({ displayName });
|
|
|
|
|
}
|
2025-01-26 23:06:49 +01:00
|
|
|
}, [displayName, setPublishReplyOptions]);
|
2025-01-26 22:25:56 +01:00
|
|
|
|
2024-04-29 13:28:04 +02:00
|
|
|
const modalContent = (
|
2025-03-01 11:48:56 +01:00
|
|
|
<animated.div
|
|
|
|
|
className={styles.container}
|
|
|
|
|
ref={nodeRef}
|
|
|
|
|
style={{
|
|
|
|
|
x,
|
|
|
|
|
y,
|
|
|
|
|
touchAction: 'none',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div className={`replyModalHandle ${styles.title}`} {...(!isMobile ? bind() : {})}>
|
2025-11-08 21:19:36 +01:00
|
|
|
{t('reply_to_cid', { cid: `CID:${parentCid && Plebbit.getShortCid(parentCid)}`, interpolation: { escapeValue: false } })}
|
2024-04-29 14:26:02 +02:00
|
|
|
<button
|
|
|
|
|
className={styles.closeIcon}
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
closeModal();
|
|
|
|
|
}}
|
|
|
|
|
title='close'
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles.replyForm}>
|
|
|
|
|
<div className={styles.name}>
|
|
|
|
|
<input
|
|
|
|
|
type='text'
|
|
|
|
|
defaultValue={displayName}
|
2024-06-05 22:18:45 +02:00
|
|
|
placeholder={displayName ? undefined : _.capitalize(t('name'))}
|
2024-08-08 17:48:45 +02:00
|
|
|
onChange={(e) => {
|
|
|
|
|
setAccount({ ...account, author: { ...account?.author, displayName: e.target.value } });
|
2025-01-30 17:09:21 +01:00
|
|
|
setPublishReplyOptions({ displayName: e.target.value });
|
2024-08-08 17:48:45 +02:00
|
|
|
}}
|
2024-04-29 14:26:02 +02:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className={styles.link}>
|
2024-05-31 15:45:48 +02:00
|
|
|
<input
|
|
|
|
|
type='text'
|
|
|
|
|
ref={urlRef}
|
|
|
|
|
placeholder={_.capitalize(t('link'))}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setUrl(e.target.value);
|
2025-01-30 17:09:21 +01:00
|
|
|
setPublishReplyOptions({ link: e.target.value });
|
2024-05-31 15:45:48 +02:00
|
|
|
}}
|
|
|
|
|
/>
|
2024-04-29 14:26:02 +02:00
|
|
|
</div>
|
|
|
|
|
<div className={styles.content}>
|
2024-12-21 00:38:15 +01:00
|
|
|
<textarea cols={48} rows={4} wrap='soft' ref={textRef} spellCheck={true} onInput={handleContentInput} onChange={handleContentChange} />
|
2024-04-29 14:26:02 +02:00
|
|
|
</div>
|
|
|
|
|
<div className={styles.footer}>
|
2024-11-04 17:34:40 +01:00
|
|
|
{url && !isAndroid && (
|
2024-05-31 15:45:48 +02:00
|
|
|
<>
|
2024-11-05 12:48:28 +01:00
|
|
|
{t('link_type')}: <LinkTypePreviewer link={url} />
|
2024-05-31 15:45:48 +02:00
|
|
|
</>
|
|
|
|
|
)}
|
2024-11-04 17:34:40 +01:00
|
|
|
{isAndroid && (
|
|
|
|
|
<span className={styles.uploadContainer}>
|
|
|
|
|
<span className={styles.uploadButton}>
|
|
|
|
|
<button onClick={handleUpload} disabled={isUploading}>
|
2024-11-04 17:42:14 +01:00
|
|
|
{isUploading ? t('uploading') : t('choose_file')}
|
2024-11-04 17:34:40 +01:00
|
|
|
</button>
|
|
|
|
|
</span>
|
2024-11-05 12:48:28 +01:00
|
|
|
<span className={styles.uploadFileName} title={uploadedFileName ? uploadedFileName : t('no_file_chosen')}>
|
|
|
|
|
{uploadedFileName ? uploadedFileName : t('no_file_chosen')}
|
|
|
|
|
</span>
|
2024-11-04 17:34:40 +01:00
|
|
|
</span>
|
|
|
|
|
)}
|
2024-05-31 15:45:48 +02:00
|
|
|
<span className={styles.spoilerButton}>
|
|
|
|
|
[
|
|
|
|
|
<label>
|
2024-08-06 20:12:07 +02:00
|
|
|
<input type='checkbox' onChange={(e) => setPublishReplyOptions({ spoiler: e.target.checked })} />
|
2024-05-31 17:29:19 +02:00
|
|
|
{_.capitalize(t('spoiler'))}?
|
2024-05-31 15:45:48 +02:00
|
|
|
</label>
|
|
|
|
|
]
|
|
|
|
|
</span>
|
2024-06-26 22:20:45 +02:00
|
|
|
<button className={styles.publishButton} onClick={onPublishReply}>
|
|
|
|
|
{t('post')}
|
|
|
|
|
</button>
|
2024-04-29 14:26:02 +02:00
|
|
|
</div>
|
2025-01-31 23:38:07 +01:00
|
|
|
{lengthError ? <div className={styles.error}>{lengthError}</div> : error && <div className={styles.error}>{error}</div>}
|
2025-01-31 23:06:50 +01:00
|
|
|
{!(isInAllView || isInSubscriptionsView) && offlineAlert}
|
2024-04-29 14:26:02 +02:00
|
|
|
</div>
|
2025-03-01 11:48:56 +01:00
|
|
|
</animated.div>
|
2024-04-29 13:28:04 +02:00
|
|
|
);
|
|
|
|
|
|
2025-03-01 11:48:56 +01:00
|
|
|
return showReplyModal && modalContent;
|
2024-04-28 20:08:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ReplyModal;
|