[Glitch] Composer Quote UI

Port d4b2e7f771 to glitch-soc

Co-authored-by: diondiondion <mail@diondiondion.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo
2025-08-18 18:52:28 +02:00
committed by Claire
parent 71cee3e472
commit 43034790a6
11 changed files with 118 additions and 16 deletions

View File

@@ -35,6 +35,7 @@ import { SecondaryPrivacyButton } from './secondary_privacy_button';
import { ThreadModeButton } from './thread_mode_button';
import { UploadForm } from './upload_form';
import { Warning } from './warning';
import { ComposeQuotedStatus } from './quoted_post';
const allowedAroundShortCode = '><\u0085\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\u0009\u000a\u000b\u000c\u000d';
@@ -324,10 +325,12 @@ class ComposeForm extends ImmutablePureComponent {
onPaste={onPaste}
autoFocus={autoFocus}
lang={this.props.lang}
className='compose-form__input'
/>
<UploadForm />
<PollForm />
<ComposeQuotedStatus />
<div className='compose-form__footer'>
<div className='compose-form__actions'>

View File

@@ -0,0 +1,27 @@
import { useMemo } from 'react';
import type { FC } from 'react';
import { Map } from 'immutable';
import { QuotedStatus } from '@/flavours/glitch/components/status_quoted';
import { useAppSelector } from '@/flavours/glitch/store';
export const ComposeQuotedStatus: FC = () => {
const quotedStatusId = useAppSelector(
(state) => state.compose.get('quoted_status_id') as string | null,
);
const quote = useMemo(
() =>
quotedStatusId
? Map<'state' | 'quoted_status', string>([
['state', 'accepted'],
['quoted_status', quotedStatusId],
])
: null,
[quotedStatusId],
);
if (!quote) {
return null;
}
return <QuotedStatus quote={quote} contextType='compose' />;
};

View File

@@ -3,10 +3,16 @@ import { connect } from 'react-redux';
import { addPoll, removePoll } from '../../../actions/compose';
import PollButton from '../components/poll_button';
const mapStateToProps = state => ({
disabled: state.getIn(['compose', 'is_uploading']) || (state.getIn(['compose', 'media_attachments']).size > 0),
active: state.getIn(['compose', 'poll']) !== null,
});
const mapStateToProps = state => {
const readyAttachmentsSize = state.compose.get('media_attachments').size ?? 0;
const hasAttachments = readyAttachmentsSize > 0 || !!state.compose.get('is_uploading');
const hasQuote = !!state.compose.get('quoted_status_id');
return ({
disabled: hasAttachments || hasQuote,
active: state.getIn(['compose', 'poll']) !== null,
});
};
const mapDispatchToProps = dispatch => ({

View File

@@ -12,9 +12,10 @@ const mapStateToProps = state => {
const attachmentsSize = readyAttachmentsSize + pendingAttachmentsSize;
const isOverLimit = attachmentsSize > state.getIn(['server', 'server', 'configuration', 'statuses', 'max_media_attachments'])-1;
const hasVideoOrAudio = state.getIn(['compose', 'media_attachments']).some(m => ['video', 'audio'].includes(m.get('type')));
const hasQuote = !!state.compose.get('quoted_status_id');
return {
disabled: isPoll || isUploading || isOverLimit || hasVideoOrAudio,
disabled: isPoll || isUploading || isOverLimit || hasVideoOrAudio || hasQuote,
resetFileKey: state.getIn(['compose', 'resetFileKey']),
};
};