Merge branch 'fix-bookmarks-reply' into 'main'

fix: reply in bookmarks

Closes #1823

See merge request soapbox-pub/soapbox!3358
merge-requests/3359/head
Alex Gleason 2025-03-24 16:51:18 +00:00
commit 82ed6d3a07
3 zmienionych plików z 22 dodań i 2 usunięć

Wyświetl plik

@ -1,6 +1,8 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { cancelReplyCompose } from 'soapbox/actions/compose.ts'; import { cancelReplyCompose } from 'soapbox/actions/compose.ts';
import { Entities } from 'soapbox/entity-store/entities.ts';
import { selectEntity } from 'soapbox/entity-store/selectors.ts';
import { Status as StatusEntity } from 'soapbox/schemas/index.ts'; import { Status as StatusEntity } from 'soapbox/schemas/index.ts';
import { makeGetStatus } from 'soapbox/selectors/index.ts'; import { makeGetStatus } from 'soapbox/selectors/index.ts';
@ -17,8 +19,11 @@ const makeMapStateToProps = () => {
const statusId = state.compose.get(composeId)?.in_reply_to!; const statusId = state.compose.get(composeId)?.in_reply_to!;
const editing = !!state.compose.get(composeId)?.id; const editing = !!state.compose.get(composeId)?.id;
const legacyStatus = getStatus(state, { id: statusId }) as LegacyStatus;
const statusEntity = selectEntity<StatusEntity>(state, Entities.STATUSES, statusId);
return { return {
status: (getStatus(state, { id: statusId }) as LegacyStatus)?.toJS() as StatusEntity, status: (legacyStatus?.toJS() ?? statusEntity) as StatusEntity,
hideActions: editing, hideActions: editing,
}; };
}; };

Wyświetl plik

@ -1,16 +1,28 @@
import { replyCompose as replyComposeAction } from 'soapbox/actions/compose.ts'; import { replyCompose as replyComposeAction } from 'soapbox/actions/compose.ts';
import { Entities } from 'soapbox/entity-store/entities.ts';
import { selectEntity } from 'soapbox/entity-store/selectors.ts';
import { useAppDispatch } from 'soapbox/hooks/useAppDispatch.ts'; import { useAppDispatch } from 'soapbox/hooks/useAppDispatch.ts';
import { useGetState } from 'soapbox/hooks/useGetState.ts'; import { useGetState } from 'soapbox/hooks/useGetState.ts';
import { normalizeStatus } from 'soapbox/normalizers/index.ts';
import { Status as StatusEntity } from 'soapbox/schemas/index.ts';
import type { Status as LegacyStatus } from 'soapbox/types/entities.ts';
export function useReplyCompose() { export function useReplyCompose() {
const getState = useGetState(); const getState = useGetState();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const replyCompose = (statusId: string) => { const replyCompose = (statusId: string) => {
const status = getState().statuses.get(statusId); let status: undefined|LegacyStatus|StatusEntity = getState().statuses.get(statusId);
if (status) { if (status) {
dispatch(replyComposeAction(status)); dispatch(replyComposeAction(status));
} }
status = selectEntity<StatusEntity>(getState(), Entities.STATUSES, statusId);
if (status) {
dispatch(replyComposeAction(normalizeStatus(status) as LegacyStatus));
}
}; };
return { replyCompose }; return { replyCompose };

Wyświetl plik

@ -143,6 +143,9 @@ export const makeGetStatus = () => {
(statusBase, statusReblog, username, filters, me, features) => { (statusBase, statusReblog, username, filters, me, features) => {
if (!statusBase) return null; if (!statusBase) return null;
const { account } = statusBase; const { account } = statusBase;
if (!account) return null;
const accountUsername = account.acct; const accountUsername = account.acct;
// Must be owner of status if username exists. // Must be owner of status if username exists.