mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 00:38:27 +00:00
[Glitch] Composer quote improvements
Port f85f0eee1b to glitch-soc
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Co-authored-by: diondiondion <mail@diondiondion.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import type { FC } from 'react';
|
||||
|
||||
import { Map } from 'immutable';
|
||||
|
||||
import { quoteComposeCancel } from '@/flavours/glitch/actions/compose_typed';
|
||||
import { QuotedStatus } from '@/flavours/glitch/components/status_quoted';
|
||||
import { useAppSelector } from '@/flavours/glitch/store';
|
||||
import { useAppDispatch, useAppSelector } from '@/flavours/glitch/store';
|
||||
|
||||
export const ComposeQuotedStatus: FC = () => {
|
||||
const quotedStatusId = useAppSelector(
|
||||
(state) => state.compose.get('quoted_status_id') as string | null,
|
||||
);
|
||||
const isEditing = useAppSelector((state) => !!state.compose.get('id'));
|
||||
const quote = useMemo(
|
||||
() =>
|
||||
quotedStatusId
|
||||
@@ -20,8 +22,17 @@ export const ComposeQuotedStatus: FC = () => {
|
||||
: null,
|
||||
[quotedStatusId],
|
||||
);
|
||||
const dispatch = useAppDispatch();
|
||||
const handleQuoteCancel = useCallback(() => {
|
||||
dispatch(quoteComposeCancel());
|
||||
}, [dispatch]);
|
||||
if (!quote) {
|
||||
return null;
|
||||
}
|
||||
return <QuotedStatus quote={quote} contextType='compose' />;
|
||||
return (
|
||||
<QuotedStatus
|
||||
quote={quote}
|
||||
onQuoteCancel={!isEditing ? handleQuoteCancel : undefined}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user