-
Notifications
You must be signed in to change notification settings - Fork 138
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
Replace declarative Video component with imperative code #10393
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { PauseId, repaintGraphicsResult } from "@replayio/protocol"; | ||
import { Cache, createCache } from "suspense"; | ||
|
||
import { ReplayClientInterface } from "shared/client/types"; | ||
|
||
export const RepaintGraphicsCache: Cache< | ||
[replayClient: ReplayClientInterface, pauseId: PauseId], | ||
repaintGraphicsResult | null | ||
> = createCache({ | ||
config: { immutable: true }, | ||
debugLabel: "RepaintGraphicsCache", | ||
getKey: ([replayClient, pauseId]) => pauseId, | ||
load: async ([replayClient, pauseId]) => { | ||
return replayClient.repaintGraphics(pauseId); | ||
}, | ||
}); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,6 +262,11 @@ export function seek({ | |
location?: Location; | ||
}): UIThunkAction<Promise<void>> { | ||
return async (dispatch, getState, { replayClient }) => { | ||
const isPlaying = getPlayback(getState()) !== null; | ||
if (isPlaying) { | ||
dispatch(stopPlayback()); | ||
} | ||
|
||
const seekLock = new Object(); | ||
dispatch(pauseRequestedAt({ seekLock, executionPoint, time, location })); | ||
dispatch(setTimelineState({ currentTime: time, playback: null })); | ||
|
@@ -378,7 +383,7 @@ export function togglePlayback(): UIThunkAction { | |
} | ||
|
||
export function startPlayback( | ||
{ beginTime: optBeginTime, endTime: optEndTime }: PlaybackOptions = { | ||
{ beginPoint = null, beginTime, endPoint = null, endTime }: PlaybackOptions = { | ||
beginTime: null, | ||
endTime: null, | ||
} | ||
|
@@ -387,21 +392,20 @@ export function startPlayback( | |
const state = getState(); | ||
const currentTime = getCurrentTime(state); | ||
|
||
const endTime = | ||
optEndTime || | ||
endTime = | ||
endTime || | ||
(getPlaybackFocusWindow(state) && replayClient.getCurrentFocusWindow()?.end.time) || | ||
getZoomRegion(state).endTime; | ||
|
||
const beginDate = Date.now(); | ||
const beginTime = | ||
optBeginTime || | ||
beginTime = | ||
beginTime || | ||
(currentTime >= endTime | ||
? (getPlaybackFocusWindow(state) && replayClient.getCurrentFocusWindow()?.begin.time) || 0 | ||
: currentTime); | ||
|
||
dispatch( | ||
setTimelineState({ | ||
playback: { beginTime, beginDate, endTime, time: beginTime }, | ||
playback: { beginPoint, beginTime, endPoint, endTime, time: beginTime }, | ||
currentTime: beginTime, | ||
}) | ||
); | ||
|
@@ -412,15 +416,15 @@ export function startPlayback( | |
|
||
export function stopPlayback(updateTime: boolean = true): UIThunkAction { | ||
return async (dispatch, getState) => { | ||
dispatch(setTimelineState({ playback: null })); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This goes along with the other change, to prevent a potential loop. |
||
|
||
if (updateTime) { | ||
const playback = getPlayback(getState()); | ||
|
||
if (playback) { | ||
dispatch(seek({ time: playback.time })); | ||
} | ||
} | ||
|
||
dispatch(setTimelineState({ playback: null })); | ||
}; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,27 @@ | ||
import clamp from "lodash/clamp"; | ||
import React from "react"; | ||
|
||
import { | ||
getCurrentTime, | ||
getHoverTime, | ||
getPlaybackPrecachedTime, | ||
getZoomRegion, | ||
} from "ui/reducers/timeline"; | ||
import { getCurrentTime, getHoverTime, getZoomRegion } from "ui/reducers/timeline"; | ||
import { useAppSelector } from "ui/setup/hooks"; | ||
import { getVisiblePosition } from "ui/utils/timeline"; | ||
|
||
export default function ProgressBars() { | ||
const currentTime = useAppSelector(getCurrentTime); | ||
const hoverTime = useAppSelector(getHoverTime); | ||
const precachedTime = useAppSelector(getPlaybackPrecachedTime); | ||
const zoomRegion = useAppSelector(getZoomRegion); | ||
|
||
const percent = getVisiblePosition({ time: currentTime, zoom: zoomRegion }) * 100; | ||
const hoverPercent = getVisiblePosition({ time: hoverTime, zoom: zoomRegion }) * 100; | ||
const precachedPercent = getVisiblePosition({ time: precachedTime, zoom: zoomRegion }) * 100; | ||
|
||
return ( | ||
<> | ||
<div className="progress-line full" /> | ||
<div | ||
className="progress-line preview-max" | ||
style={{ width: `${clamp(Math.max(hoverPercent, precachedPercent), 0, 100)}%` }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what this "pre-cached percent" state was. I don't think we really need it. Particularly since it's only used for our internal expanded/enhanced timeline UI. So I removed it to simplify things a bit. |
||
style={{ width: `${clamp(hoverPercent, 0, 100)}%` }} | ||
/> | ||
<div | ||
className="progress-line preview-min" | ||
style={{ width: `${clamp(Math.min(hoverPercent, precachedPercent), 0, 100)}%` }} | ||
style={{ width: `${clamp(hoverPercent, 0, 100)}%` }} | ||
data-hover-value={hoverPercent} | ||
/> | ||
<div | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a reasonable change. Any objections?