nicolium: wip migrations
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -1,10 +1,9 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
import HStack from '@/components/ui/hstack';
|
||||
import Icon from '@/components/ui/icon';
|
||||
import Text from '@/components/ui/text';
|
||||
import { useAppSelector } from '@/hooks/use-app-selector';
|
||||
import { makeGetStatus } from '@/selectors';
|
||||
import { useMinimalStatus } from '@/queries/statuses/use-status';
|
||||
|
||||
interface IQuotedStatusIndicator {
|
||||
/** The quoted status id. */
|
||||
@ -14,11 +13,7 @@ interface IQuotedStatusIndicator {
|
||||
}
|
||||
|
||||
const QuotedStatusIndicator: React.FC<IQuotedStatusIndicator> = ({ statusId, statusUrl }) => {
|
||||
const getStatus = useCallback(makeGetStatus(), []);
|
||||
|
||||
statusUrl = useAppSelector(
|
||||
(state) => statusUrl ?? (statusId && getStatus(state, { id: statusId })?.url),
|
||||
);
|
||||
statusUrl = useMinimalStatus(statusId).data?.url || statusUrl;
|
||||
|
||||
if (!statusUrl) return null;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useNavigate } from '@tanstack/react-router';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||
|
||||
import { cancelEventCompose, initEventEdit, submitEvent } from '@/actions/events';
|
||||
@ -23,9 +23,8 @@ import ContentTypeButton from '@/features/compose/components/content-type-button
|
||||
import { isCurrentOrFutureDate } from '@/features/compose/components/schedule-form';
|
||||
import { ComposeEditor, DatePicker } from '@/features/ui/util/async-components';
|
||||
import { useAppDispatch } from '@/hooks/use-app-dispatch';
|
||||
import { useAppSelector } from '@/hooks/use-app-selector';
|
||||
import { useInstance } from '@/hooks/use-instance';
|
||||
import { makeGetStatus } from '@/selectors';
|
||||
import { useMinimalStatus } from '@/queries/statuses/use-status';
|
||||
import { useChangeUploadCompose, useComposeActions } from '@/stores/compose';
|
||||
import { useModalsActions } from '@/stores/modals';
|
||||
import toast from '@/toast';
|
||||
@ -77,10 +76,7 @@ const EditEvent: React.FC<IEditEvent> = ({ statusId }) => {
|
||||
const { resetCompose } = useComposeActions();
|
||||
const changeUploadCompose = useChangeUploadCompose(composeId);
|
||||
|
||||
const getStatus = useCallback(makeGetStatus(), []);
|
||||
const status = useAppSelector((state) =>
|
||||
statusId ? getStatus(state, { id: statusId }) : undefined,
|
||||
);
|
||||
const { data: status } = useMinimalStatus(statusId ?? undefined);
|
||||
const {
|
||||
pleroma: {
|
||||
metadata: { description_limit: descriptionLimit },
|
||||
|
||||
@ -17,9 +17,7 @@ import {
|
||||
} from '@/features/ui/util/async-components';
|
||||
import { useAppSelector } from '@/hooks/use-app-selector';
|
||||
import { useFeatures } from '@/hooks/use-features';
|
||||
import { makeGetStatus } from '@/selectors';
|
||||
|
||||
const getStatus = makeGetStatus();
|
||||
import { useStatus } from '@/queries/statuses/use-status';
|
||||
|
||||
const EventLayout = () => {
|
||||
const { statusId } = layouts.event.useParams();
|
||||
@ -30,7 +28,7 @@ const EventLayout = () => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const status = useAppSelector((state) => getStatus(state, { id: statusId }) ?? undefined);
|
||||
const { data: status } = useStatus(statusId);
|
||||
|
||||
const event = status?.event;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import React from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import Icon from '@/components/icon';
|
||||
@ -6,8 +6,7 @@ import Modal from '@/components/ui/modal';
|
||||
import Stack from '@/components/ui/stack';
|
||||
import Text from '@/components/ui/text';
|
||||
import ReplyIndicator from '@/features/compose/components/reply-indicator';
|
||||
import { useAppSelector } from '@/hooks/use-app-selector';
|
||||
import { makeGetStatus } from '@/selectors';
|
||||
import { useMinimalStatus } from '@/queries/statuses/use-status';
|
||||
|
||||
import type { BaseModalProps } from '@/features/ui/components/modal-root';
|
||||
|
||||
@ -23,16 +22,14 @@ const BoostModal: React.FC<BaseModalProps & BoostModalProps> = ({
|
||||
visibility,
|
||||
onClose,
|
||||
}) => {
|
||||
const getStatus = useCallback(makeGetStatus(), []);
|
||||
|
||||
const status = useAppSelector((state) => getStatus(state, { id: statusId }))!;
|
||||
const { data: status } = useMinimalStatus(statusId);
|
||||
|
||||
const handleReblog = () => {
|
||||
onReblog();
|
||||
onClose('BOOST');
|
||||
};
|
||||
|
||||
const buttonText = status.reblogged ? (
|
||||
const buttonText = status?.reblogged ? (
|
||||
<FormattedMessage id='status.cancel_reblog_private' defaultMessage='Un-repost' />
|
||||
) : (
|
||||
<FormattedMessage id='status.reblog' defaultMessage='Repost' />
|
||||
|
||||
@ -34,11 +34,11 @@ type SelectedStatus = NormalizedStatus & {
|
||||
quote?: SelectedStatus;
|
||||
};
|
||||
|
||||
const useStatusQuery = (statusId?: string) => {
|
||||
const useMinimalStatus = (statusId?: string) => {
|
||||
const client = useClient();
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const statusQuery = useQuery({
|
||||
return useQuery({
|
||||
queryKey: queryKeys.statuses.show(statusId!),
|
||||
queryFn: () =>
|
||||
client.statuses.getStatus(statusId!).then((status) => {
|
||||
@ -55,6 +55,10 @@ const useStatusQuery = (statusId?: string) => {
|
||||
}),
|
||||
enabled: !!statusId,
|
||||
});
|
||||
};
|
||||
|
||||
const useStatusQuery = (statusId?: string) => {
|
||||
const statusQuery = useMinimalStatus(statusId);
|
||||
|
||||
const account = useAccount(statusQuery.data?.account_id ?? undefined);
|
||||
const { data: accounts } = useAccounts(
|
||||
@ -126,4 +130,4 @@ const useStatusContext = (statusId?: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
export { useStatus, useStatusContext, type MinifiedContext, type SelectedStatus };
|
||||
export { useMinimalStatus, useStatus, useStatusContext, type MinifiedContext, type SelectedStatus };
|
||||
|
||||
Reference in New Issue
Block a user