You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// We destructure the 'props' that were passed into this component
31
31
const{
32
-
selected,
33
-
last,
34
-
index,
35
-
sliderIndex,
32
+
selected,// boolean on whether the current index is the same as the viewIndex from 'ActionContainer'
33
+
last,// boolean on (whether the view index is less than 0) AND if (the index is the same as the last snapshot's index value in hierarchyArr) from 'ActionContainer'
34
+
index,// from snapshot.index in "ActionContainer's" 'hierarchyArr'
35
+
sliderIndex,// from tabs[currentTab] object from 'ActionContainer'
36
36
dispatch,
37
-
displayName,
38
-
componentData,
39
-
viewIndex,
37
+
displayName,// from snapshot.displayName in "ActionContainer's" 'hierarchyArr'
38
+
componentData,// from snapshot.componentData in "ActionContainer's" 'hierarchyArr'
39
+
viewIndex,// from tabs[currentTab] object from 'ActionContainer'
40
40
isCurrIndex,
41
-
handleOnkeyDown,
41
+
handleOnkeyDown,// function that allows arrows keys to jump between snapshots defined in 'ActionContainer.tsx'
letseconds: number|string;// seconds is undefined but can take a number or a string
56
+
letmilliseconds: any=componentData.actualDuration;// milliseconds is of any type and taken from the 'componentData.actualDuration'
57
+
58
+
if(Math.floor(componentData.actualDuration)>60){// if the milliseconds is greater than 60
59
+
seconds=Math.floor(componentData.actualDuration/60);// we divide our milliseconds by 60 to determine our seconds
60
+
seconds=JSON.stringify(seconds);// and we convert our seconds into a string
61
+
62
+
if(seconds.length<2){// if the seconds string is only a single digit
63
+
seconds='0'.concat(seconds);// we can add a 0 in front of it so that if 'seconds = "1"' it will come out as 'seconds = "01"'
64
+
}
65
+
milliseconds=Math.floor(componentData.actualDuration%60);// Our true milliseconds then becomes the remainder of dividing our initial milliseconds by 60
66
+
74
67
}else{
75
-
// if we haven't even reached one second yet, our seconds are 00
76
-
seconds='00';
68
+
seconds='00';// if we haven't even reached one second yet, our seconds are 00
77
69
}
78
70
79
-
// we convert our milliseconds string into a floating point number that has up to two decimal places.
milliseconds=Number.parseFloat(millisecondsasstring).toFixed(2);// we convert our milliseconds string into a floating point number that has up to two decimal places.
72
+
constarrayMilliseconds: string|number=milliseconds.split('.');// we split our milliseconds using the decimal and come out with an array of two numbers
81
73
82
-
// we split our milliseconds using the decimal and come out with an array of two numbers
Copy file name to clipboardExpand all lines: src/app/containers/ActionContainer.tsx
+6-9Lines changed: 6 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,11 @@ const resetSlider = () => {
28
28
functionActionContainer(props): JSX.Element{
29
29
const[{ tabs, currentTab, port },dispatch]=useStoreContext();// we destructure the returned context object from the invocation of the useStoreContext function. Properties not found on the initialState object (dispatch) are from the useReducer function invocation in the App component
30
30
const{ currLocation, hierarchy, sliderIndex, viewIndex }=tabs[currentTab];// we destructure the currentTab object
31
-
const{ toggleActionContainer, actionView, setActionView }=props;// we destructure our props object
31
+
const{
32
+
toggleActionContainer,// function that handles Time Jump Sidebar view from MainContainer
33
+
actionView,// local state declared in MainContainer
34
+
setActionView // function to update actionView state declared in MainContainer
35
+
}=props;
32
36
const[recordingActions,setRecordingActions]=useState(true);// We create a local state 'recordingActions' and set it to true
33
37
letactionsArr: JSX.Element[]=[];// we create an array 'actionsArr' that will hold elements we create later on
34
38
// we create an array 'hierarchyArr' that will hold objects and numbers
@@ -104,7 +108,7 @@ function ActionContainer(props): JSX.Element {
104
108
}
105
109
}
106
110
107
-
// Sort hierarchyArr by index property of each object. This will be useful when later when we build our components so that our components will be displayed in index/chronological order
111
+
// Sort hierarchyArr by index property of each object. This will be useful later when we render the components: components will be displayed in index/chronological order
// we create a map of components that are constructed from "hierarchyArr's" elements/snapshots
@@ -120,13 +124,6 @@ function ActionContainer(props): JSX.Element {
120
124
const{ index }=snapshot;// destructure index from snapshot
121
125
constselected=index===viewIndex;// boolean on whether the current index is the same as the viewIndex
122
126
constlast=viewIndex===-1&&index===hierarchyArr.length-1;// boolean on whether the view index is less than 0 and if the index is the same as the last snapshot's index value in hierarchyArr
0 commit comments