@ -53,6 +53,7 @@ import {
DidFetchNotificationType ,
DidSearchNotificationType ,
GraphCommitDateTimeSources ,
GraphMinimapMarkerTypes ,
} from '../../../../plus/webviews/graph/protocol' ;
import type { Subscription } from '../../../../subscription' ;
import { getSubscriptionTimeRemaining , SubscriptionState } from '../../../../subscription' ;
@ -351,6 +352,7 @@ export function GraphWrapper({
// Loops through all the rows and group them by day and aggregate the row.stats
const statsByDayMap = new Map < number , GraphMinimapStats > ( ) ;
const markersByDay = new Map < number , GraphMinimapMarker [ ] > ( ) ;
const enabledMinimapMarkers : GraphMinimapMarkerTypes [ ] = graphConfig ? . enabledMinimapMarkerTypes ? ? [ ] ;
let rankedShas : {
head : string | undefined ;
@ -368,10 +370,10 @@ export function GraphWrapper({
let prevDay ;
let markers ;
let headMarkers ;
let remoteMarkers ;
let headMarkers : GraphMinimapMarker [ ] ;
let remoteMarkers : GraphMinimapMarker [ ] ;
let stashMarker : StashMarker | undefined ;
let tagMarkers ;
let tagMarkers : GraphMinimapMarker [ ] ;
let row : GraphRow ;
let stat ;
let stats ;
@ -392,20 +394,31 @@ export function GraphWrapper({
} ;
}
if ( row . heads ? . length ) {
if (
row . heads ? . length &&
( enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . Head ) ||
enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . LocalBranches ) )
) {
rankedShas . branch = row . sha ;
headMarkers = [ ] ;
// eslint-disable-next-line no-loop-func
headMarkers = row . heads . map < GraphMinimapMarker > ( h = > {
row . heads . forEach ( h = > {
if ( h . isCurrentHead ) {
rankedShas . head = row . sha ;
}
return {
type : 'branch' ,
name : h.name ,
current : h.isCurrentHead ,
} ;
if (
enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . LocalBranches ) ||
( enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . Head ) && h . isCurrentHead )
) {
headMarkers . push ( {
type : 'branch' ,
name : h.name ,
current : h.isCurrentHead && enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . Head ) ,
} ) ;
}
} ) ;
markers = markersByDay . get ( day ) ;
@ -416,22 +429,33 @@ export function GraphWrapper({
}
}
if ( row . remotes ? . length ) {
if (
row . remotes ? . length &&
( enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . Upstream ) ||
enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . RemoteBranches ) )
) {
rankedShas . remote = row . sha ;
remoteMarkers = [ ] ;
// eslint-disable-next-line no-loop-func
remoteMarkers = row . remotes . map < GraphMinimapMarker > ( r = > {
row . remotes . forEach ( r = > {
let current = false ;
if ( r . current ) {
rankedShas . remote = row . sha ;
current = true ;
}
return {
type : 'remote' ,
name : ` ${ r . owner } / ${ r . name } ` ,
current : current ,
} ;
if (
enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . RemoteBranches ) ||
( enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . Upstream ) && current )
) {
remoteMarkers . push ( {
type : 'remote' ,
name : ` ${ r . owner } / ${ r . name } ` ,
current : current && enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . Upstream ) ,
} ) ;
}
} ) ;
markers = markersByDay . get ( day ) ;
@ -442,7 +466,7 @@ export function GraphWrapper({
}
}
if ( row . type === 'stash-node' ) {
if ( row . type === 'stash-node' && enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . Stashes ) ) {
stashMarker = { type : 'stash' , name : row.message } ;
markers = markersByDay . get ( day ) ;
if ( markers == null ) {
@ -452,7 +476,7 @@ export function GraphWrapper({
}
}
if ( row . tags ? . length ) {
if ( row . tags ? . length && enabledMinimapMarkers . includes ( GraphMinimapMarkerTypes . Tags ) ) {
rankedShas . tag = row . sha ;
tagMarkers = row . tags . map < GraphMinimapMarker > ( t = > ( {
@ -499,10 +523,14 @@ export function GraphWrapper({
}
return { stats : statsByDayMap , markers : markersByDay } ;
} , [ rows , graphConfig ? . minimap ] ) ;
} , [ rows , graphConfig ? . minimap , graphConfig ? . enabledMinimapMarkerTypes ]) ;
const minimapSearchResults = useMemo ( ( ) = > {
if ( ! graphConfig ? . minimap ) return undefined ;
if (
! graphConfig ? . minimap ||
! graphConfig . enabledMinimapMarkerTypes ? . includes ( GraphMinimapMarkerTypes . Highlights )
)
{ return undefined ; }
const searchResultsByDay = new Map < number , GraphMinimapSearchResultMarker > ( ) ;
@ -522,7 +550,7 @@ export function GraphWrapper({
}
return searchResultsByDay ;
} , [ searchResults , graphConfig ? . minimap ] ) ;
} , [ searchResults , graphConfig ? . minimap , graphConfig ? . enabledMinimapMarkerTypes ]) ;
const handleOnMinimapDaySelected = ( e : CustomEvent < GraphMinimapDaySelectedEventDetail > ) = > {
let { sha } = e . detail ;