feat(ui): revalidate requests slider on discover page (#2818)

pull/2927/head
Danshil Kokil Mungur 2 years ago committed by GitHub
parent f836cadd23
commit 91e0928aa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,7 +3,7 @@ import axios from 'axios';
import React, { useCallback, useEffect, useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { useToasts } from 'react-toast-notifications';
import useSWR from 'swr';
import useSWR, { mutate } from 'swr';
import { MediaStatus } from '../../../server/constants/media';
import type { MediaRequest } from '../../../server/entity/MediaRequest';
import type { QuotaResponse } from '../../../server/interfaces/api/userInterfaces';
@ -95,6 +95,7 @@ const MovieRequestModal = ({
is4k,
...overrideParams,
});
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
if (response.data) {
if (onComplete) {
@ -138,6 +139,7 @@ const MovieRequestModal = ({
const response = await axios.delete<MediaRequest>(
`/api/v1/request/${editRequest?.id}`
);
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
if (response.status === 204) {
if (onComplete) {
@ -174,6 +176,7 @@ const MovieRequestModal = ({
if (alsoApproveRequest) {
await axios.post(`/api/v1/request/${editRequest?.id}/approve`);
}
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
addToast(
<span>

@ -3,7 +3,7 @@ import axios from 'axios';
import React, { useState } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { useToasts } from 'react-toast-notifications';
import useSWR from 'swr';
import useSWR, { mutate } from 'swr';
import { ANIME_KEYWORD_ID } from '../../../server/api/themoviedb/constants';
import {
MediaRequestStatus,
@ -131,6 +131,7 @@ const TvRequestModal = ({
} else {
await axios.delete(`/api/v1/request/${editRequest.id}`);
}
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
addToast(
<span>
@ -205,6 +206,7 @@ const TvRequestModal = ({
),
...overrideParams,
});
mutate('/api/v1/request?filter=all&take=10&sort=modified&skip=0');
if (response.data) {
if (onComplete) {

Loading…
Cancel
Save