mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix performance, styling
This commit is contained in:
@@ -197,8 +197,8 @@ const PostMessage = ({ post }: PostProps) => {
|
||||
<span className={styles.editedInfo}>
|
||||
{showOriginal && <Markdown content={original?.content} />}
|
||||
<br />
|
||||
{t('comment_edited_at_timestamp', { timestamp: getFormattedDate(edit?.timestamp), interpolation: { escapeValue: false } })}
|
||||
{reason && <> {t('reason_reason', { reason: reason, interpolation: { escapeValue: false } })}</>}
|
||||
{t('comment_edited_at_timestamp', { timestamp: getFormattedDate(edit?.timestamp), interpolation: { escapeValue: false } })}{' '}
|
||||
{reason && <>{t('reason_reason', { reason: reason, interpolation: { escapeValue: false } })} </>}
|
||||
{showOriginal ? (
|
||||
<Trans
|
||||
i18nKey={'click_here_to_hide_original'}
|
||||
|
||||
@@ -154,8 +154,8 @@ const PostMessageMobile = ({ post }: PostProps) => {
|
||||
<span className={styles.editedInfo}>
|
||||
{showOriginal && <Markdown content={original?.content} />}
|
||||
<br />
|
||||
{t('comment_edited_at_timestamp', { timestamp: getFormattedDate(edit?.timestamp), interpolation: { escapeValue: false } })}
|
||||
{reason && <> {t('reason_reason', { reason: reason, interpolation: { escapeValue: false } })}</>}
|
||||
{t('comment_edited_at_timestamp', { timestamp: getFormattedDate(edit?.timestamp), interpolation: { escapeValue: false } })}{' '}
|
||||
{reason && <>{t('reason_reason', { reason: reason, interpolation: { escapeValue: false } })} </>}
|
||||
{showOriginal ? (
|
||||
<Trans
|
||||
i18nKey={'click_here_to_hide_original'}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
import { useState } from 'react';
|
||||
import useIsMobile from './use-is-mobile';
|
||||
import useSelectedTextStore from '../stores/use-selected-text-store';
|
||||
|
||||
@@ -7,33 +7,35 @@ const useReplyModal = () => {
|
||||
const [activeCid, setActiveCid] = useState<string | null>(null);
|
||||
const { resetSelectedText, setSelectedText } = useSelectedTextStore();
|
||||
|
||||
// on mobile, the position is absolute instead of fixed, so we need to calculate the top position
|
||||
// on mobile, the css position is absolute instead of fixed, so we need to calculate the top position
|
||||
const isMobile = useIsMobile();
|
||||
const [scrollY, setScrollY] = useState<number>(0);
|
||||
|
||||
const closeModal = useCallback(() => {
|
||||
const closeModal = () => {
|
||||
resetSelectedText();
|
||||
setActiveCid(null);
|
||||
setShowReplyModal(false);
|
||||
}, [resetSelectedText]);
|
||||
};
|
||||
|
||||
const openReplyModal = useCallback(
|
||||
(cid: string) => {
|
||||
let text = document.getSelection()?.toString();
|
||||
text && setSelectedText(`>${text}\n`);
|
||||
if (isMobile) {
|
||||
const currentScrollY = window.scrollY;
|
||||
setScrollY(currentScrollY);
|
||||
}
|
||||
if (activeCid && activeCid !== cid) {
|
||||
return;
|
||||
} else if (!activeCid) {
|
||||
setActiveCid(cid);
|
||||
setShowReplyModal(true);
|
||||
}
|
||||
},
|
||||
[activeCid, isMobile, setSelectedText],
|
||||
);
|
||||
const getSelectedText = () => {
|
||||
let text = document.getSelection()?.toString();
|
||||
text && setSelectedText(`>${text}\n`);
|
||||
};
|
||||
|
||||
const openReplyModal = (cid: string) => {
|
||||
getSelectedText();
|
||||
|
||||
if (isMobile) {
|
||||
const currentScrollY = window.scrollY;
|
||||
setScrollY(currentScrollY);
|
||||
}
|
||||
|
||||
if (activeCid && activeCid !== cid) {
|
||||
return;
|
||||
}
|
||||
setActiveCid(cid);
|
||||
setShowReplyModal(true);
|
||||
};
|
||||
|
||||
return { activeCid, closeModal, openReplyModal, scrollY, showReplyModal };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user