mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
fix(ui): do not display negative remaining quota (#1859)
* fix(ui): do not display negative remaining quota * fix: correct remaining quota count on API side
This commit is contained in:
@@ -307,7 +307,7 @@ export class User {
|
|||||||
limit: movieQuotaLimit,
|
limit: movieQuotaLimit,
|
||||||
used: movieQuotaUsed,
|
used: movieQuotaUsed,
|
||||||
remaining: movieQuotaLimit
|
remaining: movieQuotaLimit
|
||||||
? movieQuotaLimit - movieQuotaUsed
|
? Math.max(0, movieQuotaLimit - movieQuotaUsed)
|
||||||
: undefined,
|
: undefined,
|
||||||
restricted:
|
restricted:
|
||||||
movieQuotaLimit && movieQuotaLimit - movieQuotaUsed <= 0
|
movieQuotaLimit && movieQuotaLimit - movieQuotaUsed <= 0
|
||||||
@@ -318,7 +318,9 @@ export class User {
|
|||||||
days: tvQuotaDays,
|
days: tvQuotaDays,
|
||||||
limit: tvQuotaLimit,
|
limit: tvQuotaLimit,
|
||||||
used: tvQuotaUsed,
|
used: tvQuotaUsed,
|
||||||
remaining: tvQuotaLimit ? tvQuotaLimit - tvQuotaUsed : undefined,
|
remaining: tvQuotaLimit
|
||||||
|
? Math.max(0, tvQuotaLimit - tvQuotaUsed)
|
||||||
|
: undefined,
|
||||||
restricted:
|
restricted:
|
||||||
tvQuotaLimit && tvQuotaLimit - tvQuotaUsed <= 0 ? true : false,
|
tvQuotaLimit && tvQuotaLimit - tvQuotaUsed <= 0 ? true : false,
|
||||||
},
|
},
|
||||||
|
@@ -59,18 +59,14 @@ const QuotaDisplay: React.FC<QuotaDisplayProps> = ({
|
|||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<ProgressCircle
|
<ProgressCircle
|
||||||
className="w-8 h-8"
|
className="w-8 h-8"
|
||||||
progress={Math.max(
|
progress={Math.round(
|
||||||
0,
|
|
||||||
Math.round(
|
|
||||||
((remaining ?? quota?.remaining ?? 0) / (quota?.limit ?? 1)) * 100
|
((remaining ?? quota?.remaining ?? 0) / (quota?.limit ?? 1)) * 100
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
useHeatLevel
|
useHeatLevel
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
className={`flex items-end ${
|
className={`flex items-end ${
|
||||||
Math.max(0, remaining ?? quota?.remaining ?? 0) === 0 ||
|
(remaining ?? quota?.remaining ?? 0) <= 0 || quota?.restricted
|
||||||
quota?.restricted
|
|
||||||
? 'text-red-500'
|
? 'text-red-500'
|
||||||
: ''
|
: ''
|
||||||
}`}
|
}`}
|
||||||
@@ -79,7 +75,7 @@ const QuotaDisplay: React.FC<QuotaDisplayProps> = ({
|
|||||||
{overLimit !== undefined
|
{overLimit !== undefined
|
||||||
? intl.formatMessage(messages.notenoughseasonrequests)
|
? intl.formatMessage(messages.notenoughseasonrequests)
|
||||||
: intl.formatMessage(messages.requestsremaining, {
|
: intl.formatMessage(messages.requestsremaining, {
|
||||||
remaining: Math.max(0, remaining ?? quota?.remaining ?? 0),
|
remaining: remaining ?? quota?.remaining ?? 0,
|
||||||
type: intl.formatMessage(
|
type: intl.formatMessage(
|
||||||
mediaType === 'movie' ? messages.movie : messages.season
|
mediaType === 'movie' ? messages.movie : messages.season
|
||||||
),
|
),
|
||||||
|
@@ -134,13 +134,10 @@ const UserProfile: React.FC = () => {
|
|||||||
{quota.movie.limit ? (
|
{quota.movie.limit ? (
|
||||||
<>
|
<>
|
||||||
<ProgressCircle
|
<ProgressCircle
|
||||||
progress={Math.max(
|
progress={Math.round(
|
||||||
0,
|
|
||||||
Math.round(
|
|
||||||
((quota?.movie.remaining ?? 0) /
|
((quota?.movie.remaining ?? 0) /
|
||||||
(quota?.movie.limit ?? 1)) *
|
(quota?.movie.limit ?? 1)) *
|
||||||
100
|
100
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
useHeatLevel
|
useHeatLevel
|
||||||
className="w-8 h-8 mr-2"
|
className="w-8 h-8 mr-2"
|
||||||
@@ -193,13 +190,10 @@ const UserProfile: React.FC = () => {
|
|||||||
{quota.tv.limit ? (
|
{quota.tv.limit ? (
|
||||||
<>
|
<>
|
||||||
<ProgressCircle
|
<ProgressCircle
|
||||||
progress={Math.max(
|
progress={Math.round(
|
||||||
0,
|
|
||||||
Math.round(
|
|
||||||
((quota?.tv.remaining ?? 0) /
|
((quota?.tv.remaining ?? 0) /
|
||||||
(quota?.tv.limit ?? 1)) *
|
(quota?.tv.limit ?? 1)) *
|
||||||
100
|
100
|
||||||
)
|
|
||||||
)}
|
)}
|
||||||
useHeatLevel
|
useHeatLevel
|
||||||
className="w-8 h-8 mr-2"
|
className="w-8 h-8 mr-2"
|
||||||
|
Reference in New Issue
Block a user