Files
artcraft/app/contexts/EngineProvider.tsx
T
wilandwil 3c7630bbc9 My Movie - Bugs (#332)
- done: setup metadata in editor.js for the Generate Movie Button
- done: update endpoint, now during stylization, the upload of the
original video uses the new_video endpoint, which provides the file with
a title field
- fixed: rendered movies art style tag now show the art style's label
properly
- fixed: clicking the media link to the video brings user back to
studio.storyteller.ai/[video_url]
- fixed: completed card DOM nesting issue

potentially fixed but the product does not reflect due to server issues:
- AI Stylize videos should also take the title from the original video
and show that title

Co-authored-by: wil <wil@storyteller.ai>
2024-05-07 13:41:43 -07:00

53 lines
1.3 KiB
TypeScript

import { ReactNode, useEffect, useContext, useState } from "react";
import { AuthenticationContext } from "~/contexts/Authentication";
import { AppUiContext } from "~/contexts/AppUiContext";
import { EngineContext } from "./EngineContext";
import { signalScene, getSceneSignals } from "~/store";
import Editor from "~/pages/PageEnigma/js/editor";
interface Props {
sceneToken?: string
children: ReactNode;
}
export const EngineProvider = ({
sceneToken,
children,
}: Props) => {
const [editor, setEditor] = useState<Editor | null>(null);
const [, dispatchAppUiState] = useContext(AppUiContext);
const {authState} = useContext(AuthenticationContext);
useEffect(() => {
setEditor((curr) => {
if (curr !== null) {
console.warn("Editor Engine already exist");
return curr;
} else if (authState.sessionToken && authState.userInfo ){
return new Editor({
dispatchAppUiState,
authState,
signalScene,
getSceneSignals
});
}
return curr;
});
// }
}, [dispatchAppUiState, authState]);
useEffect(() => {
if (editor && editor.can_initialize) {
editor.initialize({
sceneToken: sceneToken || ""}
);
}
}, [editor, sceneToken]);
return (
<EngineContext.Provider value={editor}>{children}</EngineContext.Provider>
);
};