@@ -28,6 +28,9 @@ import './sidebar/sidebar';
2828
2929@customElement ( 'gl-graph-app' )
3030export class GraphApp extends SignalWatcher ( LitElement ) {
31+ private _hoverTrackingCounter = getScopedCounter ( ) ;
32+ private _selectionTrackingCounter = getScopedCounter ( ) ;
33+
3134 // use Light DOM
3235 protected override createRenderRoot ( ) : HTMLElement | DocumentFragment {
3336 return this ;
@@ -54,6 +57,63 @@ export class GraphApp extends SignalWatcher(LitElement) {
5457 @query ( 'gl-graph-minimap-container' )
5558 minimapEl : GlGraphMinimapContainer | undefined ;
5659
60+ onWebviewVisibilityChanged ( visible : boolean ) : void {
61+ if ( ! visible ) return ;
62+
63+ this . _hoverTrackingCounter . reset ( ) ;
64+ this . _selectionTrackingCounter . reset ( ) ;
65+ }
66+
67+ resetHover ( ) {
68+ this . graphHover . reset ( ) ;
69+ }
70+
71+ override render ( ) {
72+ return html `
73+ < div class ="graph ">
74+ < gl-graph-header
75+ class ="graph__header "
76+ @gl-select-commits =${ this . handleHeaderSearchNavigation }
77+ > </ gl-graph-header >
78+ < div class ="graph__workspace ">
79+ ${ when ( ! this . state . allowed , ( ) => html `< gl-graph-gate class ="graph__gate "> </ gl-graph-gate > ` ) }
80+ < main id ="main " class ="graph__panes ">
81+ < div class ="graph__graph-pane ">
82+ ${ when (
83+ this . state . config ?. minimap !== false ,
84+ ( ) => html `
85+ < gl-graph-minimap-container
86+ .activeDay =${ this . graphApp . activeDay }
87+ .disabled =${ ! this . state . config ?. minimap }
88+ .rows=${ this . state . rows ?? [ ] }
89+ .rowsStats=${ this . state . rowsStats }
90+ .dataType=${ this . state . config ?. minimapDataType ?? 'commits' }
91+ .markerTypes=${ this . state . config ?. minimapMarkerTypes ?? [ ] }
92+ .refMetadata=${ this . state . refsMetadata }
93+ .searchResults=${ this . graphApp . searchResults }
94+ .visibleDays=${ this . graphApp . visibleDays }
95+ @gl-graph-minimap-selected=${ this . handleMinimapDaySelected }
96+ > </ gl-graph-minimap-container >
97+ ` ,
98+ ) }
99+ ${ when ( this . state . config ?. sidebar , ( ) => html `< gl-graph-sidebar > </ gl-graph-sidebar > ` ) }
100+ < gl-graph-hover id ="commit-hover " distance =${ 0 } skidding =${ 15 } > </ gl-graph-hover >
101+ < gl-graph-wrapper
102+ @gl-graph-change-selection =${ this . handleGraphSelectionChanged }
103+ @gl-graph-change-visible-days =${ this . handleGraphVisibleDaysChanged }
104+ @gl-graph-mouse-leave=${ this . handleGraphMouseLeave }
105+ @gl-graph-row-context-menu=${ this . handleGraphRowContextMenu }
106+ @gl-graph-row-hover=${ this . handleGraphRowHover }
107+ @gl-graph-row-unhover=${ this . handleGraphRowUnhover }
108+ > </ gl-graph-wrapper >
109+ </ div >
110+ <!-- future: commit details -->
111+ </ main >
112+ </ div >
113+ </ div >
114+ ` ;
115+ }
116+
57117 private handleHeaderSearchNavigation ( e : CustomEventType < 'gl-select-commits' > ) {
58118 this . graph . selectCommits ( [ e . detail ] , false , true ) ;
59119 }
@@ -86,8 +146,18 @@ export class GraphApp extends SignalWatcher(LitElement) {
86146 }
87147 }
88148
89- private handleGraphSelectionChanged ( _e : CustomEventType < 'gl-graph-change-selection' > ) {
149+ private handleGraphSelectionChanged ( e : CustomEventType < 'gl-graph-change-selection' > ) {
90150 this . graphHover . hide ( ) ;
151+
152+ const count = this . _selectionTrackingCounter . next ( ) ;
153+ if ( count === 1 || count % 100 === 0 ) {
154+ queueMicrotask ( ( ) =>
155+ this . _telemetry . sendEvent ( {
156+ name : 'graph/row/selected' ,
157+ data : { rows : e . detail . selection . length , count : count } ,
158+ } ) ,
159+ ) ;
160+ }
91161 }
92162
93163 private handleGraphVisibleDaysChanged ( { detail } : CustomEventType < 'gl-graph-change-visible-days' > ) {
@@ -140,16 +210,14 @@ export class GraphApp extends SignalWatcher(LitElement) {
140210 this . graphHover . onRowUnhovered ( graphRow , relatedTarget ) ;
141211 }
142212
143- private _hoverCounter = getScopedCounter ( ) ;
144-
145213 private async getRowHoverPromise ( row : GraphRow ) {
146214 try {
147215 const request = await this . _ipc . sendRequest ( GetRowHoverRequest , {
148216 type : row . type as GitGraphRowType ,
149217 id : row . sha ,
150218 } ) ;
151219
152- const count = this . _hoverCounter . next ( ) ;
220+ const count = this . _hoverTrackingCounter . next ( ) ;
153221 if ( count === 1 || count % 100 === 0 ) {
154222 queueMicrotask ( ( ) => this . _telemetry . sendEvent ( { name : 'graph/row/hovered' , data : { count : count } } ) ) ;
155223 }
@@ -163,54 +231,4 @@ export class GraphApp extends SignalWatcher(LitElement) {
163231 private handleGraphMouseLeave ( ) {
164232 this . minimapEl ?. unselect ( undefined , true ) ;
165233 }
166-
167- resetHover ( ) {
168- this . graphHover . reset ( ) ;
169- }
170-
171- override render ( ) {
172- return html `
173- < div class ="graph ">
174- < gl-graph-header
175- class ="graph__header "
176- @gl-select-commits =${ this . handleHeaderSearchNavigation }
177- > </ gl-graph-header >
178- < div class ="graph__workspace ">
179- ${ when ( ! this . state . allowed , ( ) => html `< gl-graph-gate class ="graph__gate "> </ gl-graph-gate > ` ) }
180- < main id ="main " class ="graph__panes ">
181- < div class ="graph__graph-pane ">
182- ${ when (
183- this . state . config ?. minimap !== false ,
184- ( ) => html `
185- < gl-graph-minimap-container
186- .activeDay =${ this . graphApp . activeDay }
187- .disabled =${ ! this . state . config ?. minimap }
188- .rows=${ this . state . rows ?? [ ] }
189- .rowsStats=${ this . state . rowsStats }
190- .dataType=${ this . state . config ?. minimapDataType ?? 'commits' }
191- .markerTypes=${ this . state . config ?. minimapMarkerTypes ?? [ ] }
192- .refMetadata=${ this . state . refsMetadata }
193- .searchResults=${ this . graphApp . searchResults }
194- .visibleDays=${ this . graphApp . visibleDays }
195- @gl-graph-minimap-selected=${ this . handleMinimapDaySelected }
196- > </ gl-graph-minimap-container >
197- ` ,
198- ) }
199- ${ when ( this . state . config ?. sidebar , ( ) => html `< gl-graph-sidebar > </ gl-graph-sidebar > ` ) }
200- < gl-graph-hover id ="commit-hover " distance =${ 0 } skidding =${ 15 } > </ gl-graph-hover >
201- < gl-graph-wrapper
202- @gl-graph-change-selection =${ this . handleGraphSelectionChanged }
203- @gl-graph-change-visible-days =${ this . handleGraphVisibleDaysChanged }
204- @gl-graph-mouse-leave=${ this . handleGraphMouseLeave }
205- @gl-graph-row-context-menu=${ this . handleGraphRowContextMenu }
206- @gl-graph-row-hover=${ this . handleGraphRowHover }
207- @gl-graph-row-unhover=${ this . handleGraphRowUnhover }
208- > </ gl-graph-wrapper >
209- </ div >
210- <!-- future: commit details -->
211- </ main >
212- </ div >
213- </ div >
214- ` ;
215- }
216234}
0 commit comments