mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2026-01-15 08:23:36 -03:00
Fix ends at not always accounting for playback position (#6965)
* fix: "Ends At" not always accounting for playback position fixes #6964 * Update contributors * Remove redundant `?? 0` * Remove redundant assignments
This commit is contained in:
@@ -102,6 +102,7 @@
|
|||||||
- [Free O'Toole](https://github.com/freeotoole)
|
- [Free O'Toole](https://github.com/freeotoole)
|
||||||
- [TheBosZ](https://github.com/thebosz)
|
- [TheBosZ](https://github.com/thebosz)
|
||||||
- [qm3jp](https://github.com/qm3jp)
|
- [qm3jp](https://github.com/qm3jp)
|
||||||
|
- [johnnyg](https://github.com/johnnyg)
|
||||||
|
|
||||||
## Emby Contributors
|
## Emby Contributors
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,26 @@
|
|||||||
import React, { type FC } from 'react';
|
import React, { type FC } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import datetime from 'scripts/datetime';
|
import mediainfo from './mediainfo';
|
||||||
import globalize from 'lib/globalize';
|
|
||||||
|
|
||||||
interface EndsAtProps {
|
interface EndsAtProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
runTimeTicks: number
|
runTimeTicks: number;
|
||||||
|
positionTicks?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EndsAt: FC<EndsAtProps> = ({ runTimeTicks, className }) => {
|
const EndsAt: FC<EndsAtProps> = ({ runTimeTicks, positionTicks, className }) => {
|
||||||
const cssClass = classNames(
|
const cssClass = classNames(
|
||||||
'mediaInfoItem',
|
'mediaInfoItem',
|
||||||
'endsAt',
|
'endsAt',
|
||||||
className
|
className
|
||||||
);
|
);
|
||||||
|
|
||||||
const endTime = new Date().getTime() + (runTimeTicks / 10000);
|
const displayTime = mediainfo.getEndsAtFromPosition(runTimeTicks, positionTicks, 1, true);
|
||||||
const endDate = new Date(endTime);
|
|
||||||
const displayTime = datetime.getDisplayTime(endDate);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className={cssClass}>
|
<Box className={cssClass}>
|
||||||
{globalize.translate('EndsAtValue', displayTime)}
|
{displayTime}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ const PrimaryMediaInfo: FC<PrimaryMediaInfoProps> = ({
|
|||||||
HasSubtitles,
|
HasSubtitles,
|
||||||
MediaType,
|
MediaType,
|
||||||
RunTimeTicks,
|
RunTimeTicks,
|
||||||
|
PlaybackPositionTicks,
|
||||||
CommunityRating,
|
CommunityRating,
|
||||||
CriticRating
|
CriticRating
|
||||||
} = item;
|
} = item;
|
||||||
@@ -107,7 +108,7 @@ const PrimaryMediaInfo: FC<PrimaryMediaInfoProps> = ({
|
|||||||
&& MediaType === ItemMediaKind.Video
|
&& MediaType === ItemMediaKind.Video
|
||||||
&& RunTimeTicks
|
&& RunTimeTicks
|
||||||
&& !StartDate && (
|
&& !StartDate && (
|
||||||
<EndsAt className={infoclass} runTimeTicks={RunTimeTicks} />
|
<EndsAt className={infoclass} runTimeTicks={RunTimeTicks} positionTicks={PlaybackPositionTicks} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{getMissingIndicator?.()}
|
{getMissingIndicator?.()}
|
||||||
|
|||||||
@@ -321,11 +321,8 @@ export function getMediaInfoHtml(item, options = {}) {
|
|||||||
|
|
||||||
export function getEndsAt(item) {
|
export function getEndsAt(item) {
|
||||||
if (item.MediaType === 'Video' && item.RunTimeTicks && !item.StartDate) {
|
if (item.MediaType === 'Video' && item.RunTimeTicks && !item.StartDate) {
|
||||||
let endDate = new Date().getTime() + (item.RunTimeTicks / 10000);
|
const positionTicks = item.UserData?.PlaybackPositionTicks;
|
||||||
endDate = new Date(endDate);
|
return getEndsAtFromPosition(item.RunTimeTicks, positionTicks, 1, true);
|
||||||
|
|
||||||
const displayTime = datetime.getDisplayTime(endDate);
|
|
||||||
return globalize.translate('EndsAtValue', displayTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user