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

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

Loading…
Cancel
Save