|
|
@ -25,8 +25,7 @@ import { useState } from 'react';
|
|
|
|
import { useInView } from 'react-intersection-observer';
|
|
|
|
import { useInView } from 'react-intersection-observer';
|
|
|
|
import { defineMessages, FormattedRelativeTime, useIntl } from 'react-intl';
|
|
|
|
import { defineMessages, FormattedRelativeTime, useIntl } from 'react-intl';
|
|
|
|
import { useToasts } from 'react-toast-notifications';
|
|
|
|
import { useToasts } from 'react-toast-notifications';
|
|
|
|
import useSWR from 'swr';
|
|
|
|
import useSWR, { mutate } from 'swr';
|
|
|
|
import useSWRMutation from 'swr/mutation';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
const messages = defineMessages({
|
|
|
|
seasons: '{seasonCount, plural, one {Season} other {Seasons}}',
|
|
|
|
seasons: '{seasonCount, plural, one {Season} other {Seasons}}',
|
|
|
@ -63,6 +62,7 @@ const RequestItemError = ({
|
|
|
|
const deleteRequest = async () => {
|
|
|
|
const deleteRequest = async () => {
|
|
|
|
await axios.delete(`/api/v1/media/${requestData?.media.id}`);
|
|
|
|
await axios.delete(`/api/v1/media/${requestData?.media.id}`);
|
|
|
|
revalidateList();
|
|
|
|
revalidateList();
|
|
|
|
|
|
|
|
mutate('/api/v1/request/count');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const { plexUrl, plexUrl4k } = useDeepLinks({
|
|
|
|
const { plexUrl, plexUrl4k } = useDeepLinks({
|
|
|
@ -307,22 +307,12 @@ const RequestItem = ({ request, revalidateList }: RequestItemProps) => {
|
|
|
|
|
|
|
|
|
|
|
|
const [isRetrying, setRetrying] = useState(false);
|
|
|
|
const [isRetrying, setRetrying] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
const fetchRequestsCount = async () => {
|
|
|
|
|
|
|
|
const response = await axios.get('/api/v1/request/count');
|
|
|
|
|
|
|
|
return response.data;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { trigger: requestTrigger } = useSWRMutation(
|
|
|
|
|
|
|
|
'/api/v1/request/count',
|
|
|
|
|
|
|
|
fetchRequestsCount
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const modifyRequest = async (type: 'approve' | 'decline') => {
|
|
|
|
const modifyRequest = async (type: 'approve' | 'decline') => {
|
|
|
|
const response = await axios.post(`/api/v1/request/${request.id}/${type}`);
|
|
|
|
const response = await axios.post(`/api/v1/request/${request.id}/${type}`);
|
|
|
|
|
|
|
|
|
|
|
|
if (response) {
|
|
|
|
if (response) {
|
|
|
|
revalidate();
|
|
|
|
revalidate();
|
|
|
|
requestTrigger();
|
|
|
|
mutate('/api/v1/request/count');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -330,7 +320,7 @@ const RequestItem = ({ request, revalidateList }: RequestItemProps) => {
|
|
|
|
await axios.delete(`/api/v1/request/${request.id}`);
|
|
|
|
await axios.delete(`/api/v1/request/${request.id}`);
|
|
|
|
|
|
|
|
|
|
|
|
revalidateList();
|
|
|
|
revalidateList();
|
|
|
|
requestTrigger();
|
|
|
|
mutate('/api/v1/request/count');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const retryRequest = async () => {
|
|
|
|
const retryRequest = async () => {
|
|
|
|