Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Update FlowManager in Managed Player state if a new one is passed in #585

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions react/player/src/manager/managed-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export const usePersistentStateMachine = (options: {
return unsub;
}, []);

return { managedState, state };
return { state, managedState };
};

/**
Expand All @@ -252,7 +252,9 @@ export const usePersistentStateMachine = (options: {
*
* `suspense` must be enabled to wait for results in flight.
*/
export const ManagedPlayer = (props: ManagedPlayerProps) => {
export const ManagedPlayer = (
props: ManagedPlayerProps,
): React.ReactElement | null => {
const { withRequestTime, RequestTimeMetricsPlugin } = useRequestTime();

const { state, managedState } = usePersistentStateMachine({
Expand Down Expand Up @@ -284,6 +286,12 @@ export const ManagedPlayer = (props: ManagedPlayerProps) => {
};
}, [props.manager, state?.context.reactPlayer.player, state?.value]);

React.useEffect(() => {
if (managedState.state) {
managedState.state.context.manager = props.manager;
}
}, [props.manager]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this feels like we should be terminating the old managed-player before picking up with the new one?

Copy link
Member Author

@KetanReddy KetanReddy Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this was just me hacking things together to test if this was the source of the issue. In theory a new Flow Manager should only be passed when managed player is in a completed state before the pending state builds the next function called later in the pending state. If the parent app wants to override the initial Flow Manager it started player with, it should only be able to do so between flows.


if (state?.value === "error") {
if (props.fallbackComponent) {
return (
Expand Down