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]);
|
}, [session.sessionId]);
|
||||||
|
|
||||||
|
const { firstVisualEvent: visualOffset, messagesProcessed } = contextValue.store?.get() || {};
|
||||||
|
|
||||||
React.useEffect(() => {
|
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)
|
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(() => {
|
React.useEffect(() => {
|
||||||
if (noteItem !== undefined) {
|
if (noteItem !== undefined) {
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,7 @@ function EventsBlock(props: IProps) {
|
||||||
const filteredLength = filteredEvents?.length || 0;
|
const filteredLength = filteredEvents?.length || 0;
|
||||||
const notesWithEvtsLength = notesWithEvents?.length || 0;
|
const notesWithEvtsLength = notesWithEvents?.length || 0;
|
||||||
const notesLength = notes.length;
|
const notesLength = notes.length;
|
||||||
const eventListNow = Object.values(tabStates).reduce((acc: any[], tab) => {
|
const eventListNow = Object.values(tabStates)[0]?.eventListNow || [];
|
||||||
return acc.concat(tab.eventListNow)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const currentTimeEventIndex = eventListNow.length > 0 ? eventListNow.length - 1 : 0;
|
const currentTimeEventIndex = eventListNow.length > 0 ? eventListNow.length - 1 : 0;
|
||||||
const usedEvents = React.useMemo(() => {
|
const usedEvents = React.useMemo(() => {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ function getTimelinePosition(value: number, scale: number) {
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
issues: Issue[]
|
issues: Issue[]
|
||||||
eventsLength: number
|
|
||||||
setTimelineHoverTime: (t: number) => void
|
setTimelineHoverTime: (t: number) => void
|
||||||
startedAt: number
|
startedAt: number
|
||||||
tooltipVisible: boolean
|
tooltipVisible: boolean
|
||||||
|
|
@ -43,18 +42,16 @@ function Timeline(props: IProps) {
|
||||||
devtoolsLoading,
|
devtoolsLoading,
|
||||||
domLoading,
|
domLoading,
|
||||||
tabStates,
|
tabStates,
|
||||||
|
eventCount,
|
||||||
} = store.get()
|
} = store.get()
|
||||||
const { issues, eventsLength } = props;
|
const { issues } = props;
|
||||||
const notes = notesStore.sessionNotes;
|
const notes = notesStore.sessionNotes;
|
||||||
|
|
||||||
const progressRef = useRef<HTMLDivElement>(null)
|
const progressRef = useRef<HTMLDivElement>(null)
|
||||||
const timelineRef = useRef<HTMLDivElement>(null)
|
const timelineRef = useRef<HTMLDivElement>(null)
|
||||||
const events = React.useMemo(() => {
|
const events = React.useMemo(() => {
|
||||||
// console.log(eventsLength, tabStates)
|
return Object.values(tabStates)[0]?.eventList || []
|
||||||
return Object.keys(tabStates).length > 0 ? Object.keys(tabStates).reduce((acc, tabId) => {
|
}, [eventCount])
|
||||||
return acc.concat(tabStates[tabId].eventList)
|
|
||||||
}, []) : []
|
|
||||||
}, [eventsLength])
|
|
||||||
|
|
||||||
const scale = 100 / endTime;
|
const scale = 100 / endTime;
|
||||||
|
|
||||||
|
|
@ -222,7 +219,6 @@ function Timeline(props: IProps) {
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
(state: any) => ({
|
(state: any) => ({
|
||||||
eventsLength: state.getIn(['sessions', 'current'])?.notesWithEvents?.length || 0,
|
|
||||||
issues: state.getIn(['sessions', 'current']).issues || [],
|
issues: state.getIn(['sessions', 'current']).issues || [],
|
||||||
startedAt: state.getIn(['sessions', 'current']).startedAt || 0,
|
startedAt: state.getIn(['sessions', 'current']).startedAt || 0,
|
||||||
tooltipVisible: state.getIn(['sessions', 'timeLineTooltip', 'isVisible']),
|
tooltipVisible: state.getIn(['sessions', 'timeLineTooltip', 'isVisible']),
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ interface RawList {
|
||||||
export interface State extends ScreenState {
|
export interface State extends ScreenState {
|
||||||
skipIntervals: SkipInterval[];
|
skipIntervals: SkipInterval[];
|
||||||
connType?: string;
|
connType?: string;
|
||||||
|
eventCount: number;
|
||||||
connBandwidth?: number;
|
connBandwidth?: number;
|
||||||
location?: string;
|
location?: string;
|
||||||
tabStates: {
|
tabStates: {
|
||||||
|
|
@ -67,6 +68,7 @@ export default class MessageManager {
|
||||||
static INITIAL_STATE: State = {
|
static INITIAL_STATE: State = {
|
||||||
...SCREEN_INITIAL_STATE,
|
...SCREEN_INITIAL_STATE,
|
||||||
tabStates: {},
|
tabStates: {},
|
||||||
|
eventCount: 0,
|
||||||
skipIntervals: [],
|
skipIntervals: [],
|
||||||
error: false,
|
error: false,
|
||||||
ready: false,
|
ready: false,
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,19 @@ export default class TabSessionManager {
|
||||||
this.locationEventManager.append(e);
|
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>) {
|
updateLocalState(state: Partial<TabState>) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue