Fix marker time setting in v2.5 UI (#396)

This commit is contained in:
WithoutPants 2020-03-13 19:58:13 +11:00 committed by GitHub
parent 3de6955a9e
commit 6f5f3112e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View file

@ -9,6 +9,7 @@ import {
MarkerTitleSuggest
} from "src/components/Shared";
import { useToast } from "src/hooks";
import { JWUtils } from "src/utils";
interface IFormFields {
title: string;
@ -20,14 +21,12 @@ interface IFormFields {
interface ISceneMarkerForm {
sceneID: string;
editingMarker?: GQL.SceneMarkerDataFragment;
playerPosition?: number;
onClose: () => void;
}
export const SceneMarkerForm: React.FC<ISceneMarkerForm> = ({
sceneID,
editingMarker,
playerPosition,
onClose
}) => {
const [sceneMarkerCreate] = StashService.useSceneMarkerCreate();
@ -81,7 +80,7 @@ export const SceneMarkerForm: React.FC<ISceneMarkerForm> = ({
onReset={() =>
fieldProps.form.setFieldValue(
"seconds",
Math.round(playerPosition ?? 0)
Math.round(JWUtils.getPlayer()?.getPosition() ?? 0)
)
}
numericValue={Number.parseInt(fieldProps.field.value ?? "0", 10)}
@ -116,7 +115,8 @@ export const SceneMarkerForm: React.FC<ISceneMarkerForm> = ({
const values: IFormFields = {
title: editingMarker?.title ?? "",
seconds: (
editingMarker?.seconds ?? Math.round(playerPosition ?? 0)
editingMarker?.seconds ??
Math.round(JWUtils.getPlayer()?.getPosition() ?? 0)
).toString(),
primaryTagId: editingMarker?.primary_tag.id ?? "",
tagIds: editingMarker?.tags.map(tag => tag.id) ?? []

View file

@ -2,7 +2,6 @@ import React, { useState } from "react";
import { Button } from "react-bootstrap";
import * as GQL from "src/core/generated-graphql";
import { WallPanel } from "src/components/Wall/WallPanel";
import { JWUtils } from "src/utils";
import { PrimaryTags } from "./PrimaryTags";
import { SceneMarkerForm } from "./SceneMarkerForm";
@ -19,8 +18,6 @@ export const SceneMarkersPanel: React.FC<ISceneMarkersPanelProps> = (
GQL.SceneMarkerDataFragment
>();
const jwplayer = JWUtils.getPlayer();
function onOpenEditor(marker?: GQL.SceneMarkerDataFragment) {
setIsEditorOpen(true);
setEditingMarker(marker ?? undefined);
@ -40,7 +37,6 @@ export const SceneMarkersPanel: React.FC<ISceneMarkersPanelProps> = (
<SceneMarkerForm
sceneID={props.scene.id}
editingMarker={editingMarker}
playerPosition={jwplayer.getPlayer?.().playerPosition}
onClose={closeEditor}
/>
);