|
|
|
@ -77,13 +77,13 @@ const RequestButton = ({
|
|
|
|
|
(request) => request.status === MediaRequestStatus.PENDING && request.is4k
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Current user's pending request, or the first pending request
|
|
|
|
|
const activeRequest = useMemo(() => {
|
|
|
|
|
return activeRequests && activeRequests.length > 0
|
|
|
|
|
? activeRequests.find((request) => request.requestedBy.id === user?.id) ??
|
|
|
|
|
activeRequests[0]
|
|
|
|
|
: undefined;
|
|
|
|
|
}, [activeRequests, user]);
|
|
|
|
|
|
|
|
|
|
const active4kRequest = useMemo(() => {
|
|
|
|
|
return active4kRequests && active4kRequests.length > 0
|
|
|
|
|
? active4kRequests.find(
|
|
|
|
@ -121,54 +121,9 @@ const RequestButton = ({
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const buttons: ButtonOption[] = [];
|
|
|
|
|
if (
|
|
|
|
|
(!media || media.status === MediaStatus.UNKNOWN) &&
|
|
|
|
|
hasPermission(
|
|
|
|
|
[
|
|
|
|
|
Permission.REQUEST,
|
|
|
|
|
mediaType === 'movie'
|
|
|
|
|
? Permission.REQUEST_MOVIE
|
|
|
|
|
: Permission.REQUEST_TV,
|
|
|
|
|
],
|
|
|
|
|
{ type: 'or' }
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
buttons.push({
|
|
|
|
|
id: 'request',
|
|
|
|
|
text: intl.formatMessage(globalMessages.request),
|
|
|
|
|
action: () => {
|
|
|
|
|
setEditRequest(false);
|
|
|
|
|
setShowRequestModal(true);
|
|
|
|
|
},
|
|
|
|
|
svg: <DownloadIcon />,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
(!media || media.status4k === MediaStatus.UNKNOWN) &&
|
|
|
|
|
hasPermission(
|
|
|
|
|
[
|
|
|
|
|
Permission.REQUEST_4K,
|
|
|
|
|
mediaType === 'movie'
|
|
|
|
|
? Permission.REQUEST_4K_MOVIE
|
|
|
|
|
: Permission.REQUEST_4K_TV,
|
|
|
|
|
],
|
|
|
|
|
{ type: 'or' }
|
|
|
|
|
) &&
|
|
|
|
|
((settings.currentSettings.movie4kEnabled && mediaType === 'movie') ||
|
|
|
|
|
(settings.currentSettings.series4kEnabled && mediaType === 'tv'))
|
|
|
|
|
) {
|
|
|
|
|
buttons.push({
|
|
|
|
|
id: 'request4k',
|
|
|
|
|
text: intl.formatMessage(globalMessages.request4k),
|
|
|
|
|
action: () => {
|
|
|
|
|
setEditRequest(false);
|
|
|
|
|
setShowRequest4kModal(true);
|
|
|
|
|
},
|
|
|
|
|
svg: <DownloadIcon />,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If there are pending requests, show request management options first
|
|
|
|
|
if (activeRequest || active4kRequest) {
|
|
|
|
|
if (
|
|
|
|
|
activeRequest &&
|
|
|
|
|
(activeRequest.requestedBy.id === user?.id ||
|
|
|
|
@ -186,23 +141,6 @@ const RequestButton = ({
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
active4kRequest &&
|
|
|
|
|
(active4kRequest.requestedBy.id === user?.id ||
|
|
|
|
|
(active4kRequests?.length === 1 &&
|
|
|
|
|
hasPermission(Permission.MANAGE_REQUESTS)))
|
|
|
|
|
) {
|
|
|
|
|
buttons.push({
|
|
|
|
|
id: 'active-4k-request',
|
|
|
|
|
text: intl.formatMessage(messages.viewrequest4k),
|
|
|
|
|
action: () => {
|
|
|
|
|
setEditRequest(true);
|
|
|
|
|
setShowRequest4kModal(true);
|
|
|
|
|
},
|
|
|
|
|
svg: <InformationCircleIcon />,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
activeRequest &&
|
|
|
|
|
hasPermission(Permission.MANAGE_REQUESTS) &&
|
|
|
|
@ -226,9 +164,7 @@ const RequestButton = ({
|
|
|
|
|
svg: <XIcon />,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
} else if (
|
|
|
|
|
activeRequests &&
|
|
|
|
|
activeRequests.length > 0 &&
|
|
|
|
|
hasPermission(Permission.MANAGE_REQUESTS) &&
|
|
|
|
@ -258,6 +194,23 @@ const RequestButton = ({
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
active4kRequest &&
|
|
|
|
|
(active4kRequest.requestedBy.id === user?.id ||
|
|
|
|
|
(active4kRequests?.length === 1 &&
|
|
|
|
|
hasPermission(Permission.MANAGE_REQUESTS)))
|
|
|
|
|
) {
|
|
|
|
|
buttons.push({
|
|
|
|
|
id: 'active-4k-request',
|
|
|
|
|
text: intl.formatMessage(messages.viewrequest4k),
|
|
|
|
|
action: () => {
|
|
|
|
|
setEditRequest(true);
|
|
|
|
|
setShowRequest4kModal(true);
|
|
|
|
|
},
|
|
|
|
|
svg: <InformationCircleIcon />,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
active4kRequest &&
|
|
|
|
|
hasPermission(Permission.MANAGE_REQUESTS) &&
|
|
|
|
@ -281,9 +234,7 @@ const RequestButton = ({
|
|
|
|
|
svg: <XIcon />,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
} else if (
|
|
|
|
|
active4kRequests &&
|
|
|
|
|
active4kRequests.length > 0 &&
|
|
|
|
|
hasPermission(Permission.MANAGE_REQUESTS) &&
|
|
|
|
@ -312,8 +263,31 @@ const RequestButton = ({
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Standard request button
|
|
|
|
|
if (
|
|
|
|
|
(!media || media.status === MediaStatus.UNKNOWN) &&
|
|
|
|
|
hasPermission(
|
|
|
|
|
[
|
|
|
|
|
Permission.REQUEST,
|
|
|
|
|
mediaType === 'movie'
|
|
|
|
|
? Permission.REQUEST_MOVIE
|
|
|
|
|
: Permission.REQUEST_TV,
|
|
|
|
|
],
|
|
|
|
|
{ type: 'or' }
|
|
|
|
|
)
|
|
|
|
|
) {
|
|
|
|
|
buttons.push({
|
|
|
|
|
id: 'request',
|
|
|
|
|
text: intl.formatMessage(globalMessages.request),
|
|
|
|
|
action: () => {
|
|
|
|
|
setEditRequest(false);
|
|
|
|
|
setShowRequestModal(true);
|
|
|
|
|
},
|
|
|
|
|
svg: <DownloadIcon />,
|
|
|
|
|
});
|
|
|
|
|
} else if (
|
|
|
|
|
mediaType === 'tv' &&
|
|
|
|
|
(!activeRequest || activeRequest.requestedBy.id !== user?.id) &&
|
|
|
|
|
hasPermission([Permission.REQUEST, Permission.REQUEST_TV], {
|
|
|
|
@ -335,7 +309,31 @@ const RequestButton = ({
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4K request button
|
|
|
|
|
if (
|
|
|
|
|
(!media || media.status4k === MediaStatus.UNKNOWN) &&
|
|
|
|
|
hasPermission(
|
|
|
|
|
[
|
|
|
|
|
Permission.REQUEST_4K,
|
|
|
|
|
mediaType === 'movie'
|
|
|
|
|
? Permission.REQUEST_4K_MOVIE
|
|
|
|
|
: Permission.REQUEST_4K_TV,
|
|
|
|
|
],
|
|
|
|
|
{ type: 'or' }
|
|
|
|
|
) &&
|
|
|
|
|
((settings.currentSettings.movie4kEnabled && mediaType === 'movie') ||
|
|
|
|
|
(settings.currentSettings.series4kEnabled && mediaType === 'tv'))
|
|
|
|
|
) {
|
|
|
|
|
buttons.push({
|
|
|
|
|
id: 'request4k',
|
|
|
|
|
text: intl.formatMessage(globalMessages.request4k),
|
|
|
|
|
action: () => {
|
|
|
|
|
setEditRequest(false);
|
|
|
|
|
setShowRequest4kModal(true);
|
|
|
|
|
},
|
|
|
|
|
svg: <DownloadIcon />,
|
|
|
|
|
});
|
|
|
|
|
} else if (
|
|
|
|
|
mediaType === 'tv' &&
|
|
|
|
|
(!active4kRequest || active4kRequest.requestedBy.id !== user?.id) &&
|
|
|
|
|
hasPermission([Permission.REQUEST_4K, Permission.REQUEST_4K_TV], {
|
|
|
|
|