feat(ui): fix events reactivity and update order
This commit is contained in:
parent
f9a5e6d5d5
commit
837d5ebeb3
5 changed files with 24 additions and 15 deletions
|
|
@ -66,13 +66,14 @@ function WebPlayer(props: any) {
|
|||
}
|
||||
}, [session.sessionId]);
|
||||
|
||||
const { firstVisualEvent: visualOffset, messagesProcessed } = contextValue.store?.get() || {};
|
||||
|
||||
React.useEffect(() => {
|
||||
if (session.events.length > 0 || session.errors.length > 0) {
|
||||
if (messagesProcessed && session.events.length > 0 || session.errors.length > 0) {
|
||||
contextValue.player?.updateLists?.(session)
|
||||
}
|
||||
}, [session.events, session.errors, contextValue.player])
|
||||
}, [session.events, session.errors, contextValue.player, messagesProcessed])
|
||||
|
||||
const { firstVisualEvent: visualOffset, messagesProcessed } = contextValue.store?.get() || {}
|
||||
|
||||
React.useEffect(() => {
|
||||
if (noteItem !== undefined) {
|
||||
|
|
|
|||
|
|
@ -53,9 +53,7 @@ function EventsBlock(props: IProps) {
|
|||
const filteredLength = filteredEvents?.length || 0;
|
||||
const notesWithEvtsLength = notesWithEvents?.length || 0;
|
||||
const notesLength = notes.length;
|
||||
const eventListNow = Object.values(tabStates).reduce((acc: any[], tab) => {
|
||||
return acc.concat(tab.eventListNow)
|
||||
}, [])
|
||||
const eventListNow = Object.values(tabStates)[0]?.eventListNow || [];
|
||||
|
||||
const currentTimeEventIndex = eventListNow.length > 0 ? eventListNow.length - 1 : 0;
|
||||
const usedEvents = React.useMemo(() => {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ function getTimelinePosition(value: number, scale: number) {
|
|||
|
||||
interface IProps {
|
||||
issues: Issue[]
|
||||
eventsLength: number
|
||||
setTimelineHoverTime: (t: number) => void
|
||||
startedAt: number
|
||||
tooltipVisible: boolean
|
||||
|
|
@ -43,18 +42,16 @@ function Timeline(props: IProps) {
|
|||
devtoolsLoading,
|
||||
domLoading,
|
||||
tabStates,
|
||||
eventCount,
|
||||
} = store.get()
|
||||
const { issues, eventsLength } = props;
|
||||
const { issues } = props;
|
||||
const notes = notesStore.sessionNotes;
|
||||
|
||||
const progressRef = useRef<HTMLDivElement>(null)
|
||||
const timelineRef = useRef<HTMLDivElement>(null)
|
||||
const events = React.useMemo(() => {
|
||||
// console.log(eventsLength, tabStates)
|
||||
return Object.keys(tabStates).length > 0 ? Object.keys(tabStates).reduce((acc, tabId) => {
|
||||
return acc.concat(tabStates[tabId].eventList)
|
||||
}, []) : []
|
||||
}, [eventsLength])
|
||||
return Object.values(tabStates)[0]?.eventList || []
|
||||
}, [eventCount])
|
||||
|
||||
const scale = 100 / endTime;
|
||||
|
||||
|
|
@ -222,7 +219,6 @@ function Timeline(props: IProps) {
|
|||
|
||||
export default connect(
|
||||
(state: any) => ({
|
||||
eventsLength: state.getIn(['sessions', 'current'])?.notesWithEvents?.length || 0,
|
||||
issues: state.getIn(['sessions', 'current']).issues || [],
|
||||
startedAt: state.getIn(['sessions', 'current']).startedAt || 0,
|
||||
tooltipVisible: state.getIn(['sessions', 'timeLineTooltip', 'isVisible']),
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ interface RawList {
|
|||
export interface State extends ScreenState {
|
||||
skipIntervals: SkipInterval[];
|
||||
connType?: string;
|
||||
eventCount: number;
|
||||
connBandwidth?: number;
|
||||
location?: string;
|
||||
tabStates: {
|
||||
|
|
@ -67,6 +68,7 @@ export default class MessageManager {
|
|||
static INITIAL_STATE: State = {
|
||||
...SCREEN_INITIAL_STATE,
|
||||
tabStates: {},
|
||||
eventCount: 0,
|
||||
skipIntervals: [],
|
||||
error: false,
|
||||
ready: false,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,19 @@ export default class TabSessionManager {
|
|||
this.locationEventManager.append(e);
|
||||
}
|
||||
})
|
||||
this.updateLocalState({ ...this.lists.getFullListsState() });
|
||||
const eventCount = lists?.event?.length || 0
|
||||
|
||||
const currentState = this.state.get()
|
||||
this.state.update({
|
||||
eventCount: currentState.eventCount + eventCount,
|
||||
tabStates: {
|
||||
...currentState.tabStates,
|
||||
[this.id]: {
|
||||
...currentState.tabStates[this.id],
|
||||
...this.lists.getFullListsState(),
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
updateLocalState(state: Partial<TabState>) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue