mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-03 04:28:31 +01:00
fix: update request status in poster on search scree
This commit is contained in:
@@ -30,8 +30,9 @@ import { writeErrorLog } from "@/utils/log";
|
|||||||
import DiscoverSlider from "@/utils/jellyseerr/server/entity/DiscoverSlider";
|
import DiscoverSlider from "@/utils/jellyseerr/server/entity/DiscoverSlider";
|
||||||
import {
|
import {
|
||||||
CombinedCredit,
|
CombinedCredit,
|
||||||
PersonDetails
|
PersonDetails,
|
||||||
} from "@/utils/jellyseerr/server/models/Person";
|
} from "@/utils/jellyseerr/server/models/Person";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
interface SearchParams {
|
interface SearchParams {
|
||||||
query: string;
|
query: string;
|
||||||
@@ -220,7 +221,12 @@ export class JellyseerrApi {
|
|||||||
|
|
||||||
async personCombinedCredits(id: number | string): Promise<CombinedCredit> {
|
async personCombinedCredits(id: number | string): Promise<CombinedCredit> {
|
||||||
return this.axios
|
return this.axios
|
||||||
?.get<CombinedCredit>(Endpoints.API_V1 + Endpoints.PERSON + `/${id}` + Endpoints.COMBINED_CREDITS)
|
?.get<CombinedCredit>(
|
||||||
|
Endpoints.API_V1 +
|
||||||
|
Endpoints.PERSON +
|
||||||
|
`/${id}` +
|
||||||
|
Endpoints.COMBINED_CREDITS
|
||||||
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
return response?.data;
|
return response?.data;
|
||||||
});
|
});
|
||||||
@@ -260,15 +266,20 @@ export class JellyseerrApi {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
imageProxy(path?: string, tmdbPath: string = 'original', width: number = 1920, quality: number = 75) {
|
imageProxy(
|
||||||
return path ? (
|
path?: string,
|
||||||
this.axios.defaults.baseURL +
|
tmdbPath: string = "original",
|
||||||
`/_next/image?` +
|
width: number = 1920,
|
||||||
new URLSearchParams(
|
quality: number = 75
|
||||||
`url=https://image.tmdb.org/t/p/${tmdbPath}/${path}&w=${width}&q=${quality}`
|
) {
|
||||||
).toString()
|
return path
|
||||||
) :
|
? this.axios.defaults.baseURL +
|
||||||
this.axios?.defaults.baseURL + `/images/overseerr_poster_not_found_logo_top.png`;
|
`/_next/image?` +
|
||||||
|
new URLSearchParams(
|
||||||
|
`url=https://image.tmdb.org/t/p/${tmdbPath}/${path}&w=${width}&q=${quality}`
|
||||||
|
).toString()
|
||||||
|
: this.axios?.defaults.baseURL +
|
||||||
|
`/images/overseerr_poster_not_found_logo_top.png`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async submitIssue(mediaId: number, issueType: IssueType, message: string) {
|
async submitIssue(mediaId: number, issueType: IssueType, message: string) {
|
||||||
@@ -344,6 +355,7 @@ const jellyseerrUserAtom = atom(storage.get<JellyseerrUser>(JELLYSEERR_USER));
|
|||||||
export const useJellyseerr = () => {
|
export const useJellyseerr = () => {
|
||||||
const [jellyseerrUser, setJellyseerrUser] = useAtom(jellyseerrUserAtom);
|
const [jellyseerrUser, setJellyseerrUser] = useAtom(jellyseerrUserAtom);
|
||||||
const [settings, updateSettings] = useSettings();
|
const [settings, updateSettings] = useSettings();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const jellyseerrApi = useMemo(() => {
|
const jellyseerrApi = useMemo(() => {
|
||||||
const cookies = storage.get<string[]>(JELLYSEERR_COOKIES);
|
const cookies = storage.get<string[]>(JELLYSEERR_COOKIES);
|
||||||
@@ -361,12 +373,16 @@ export const useJellyseerr = () => {
|
|||||||
|
|
||||||
const requestMedia = useCallback(
|
const requestMedia = useCallback(
|
||||||
(title: string, request: MediaRequestBody, onSuccess?: () => void) => {
|
(title: string, request: MediaRequestBody, onSuccess?: () => void) => {
|
||||||
jellyseerrApi?.request?.(request)?.then((mediaRequest) => {
|
jellyseerrApi?.request?.(request)?.then(async (mediaRequest) => {
|
||||||
|
await queryClient.invalidateQueries({
|
||||||
|
queryKey: ["search", "jellyseerr"],
|
||||||
|
});
|
||||||
|
|
||||||
switch (mediaRequest.status) {
|
switch (mediaRequest.status) {
|
||||||
case MediaRequestStatus.PENDING:
|
case MediaRequestStatus.PENDING:
|
||||||
case MediaRequestStatus.APPROVED:
|
case MediaRequestStatus.APPROVED:
|
||||||
toast.success(`Requested ${title}!`);
|
toast.success(`Requested ${title}!`);
|
||||||
onSuccess?.()
|
onSuccess?.();
|
||||||
break;
|
break;
|
||||||
case MediaRequestStatus.DECLINED:
|
case MediaRequestStatus.DECLINED:
|
||||||
toast.error(`You don't have permission to request!`);
|
toast.error(`You don't have permission to request!`);
|
||||||
|
|||||||
Reference in New Issue
Block a user