Skip to content

Commit 5292ac5

Browse files
committed
Flattens state access
1 parent 7e5414d commit 5292ac5

File tree

4 files changed

+218
-126
lines changed

4 files changed

+218
-126
lines changed

src/webviews/apps/plus/graph/graph-app.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,27 @@ export class GraphApp extends SignalWatcher(LitElement) {
7272
@gl-select-commits=${this.handleHeaderSearchNavigation}
7373
></gl-graph-header>
7474
<div class="graph__workspace">
75-
${when(
76-
!this.graphState.state.allowed,
77-
() => html`<gl-graph-gate class="graph__gate"></gl-graph-gate>`,
78-
)}
75+
${when(!this.graphState.allowed, () => html`<gl-graph-gate class="graph__gate"></gl-graph-gate>`)}
7976
<main id="main" class="graph__panes">
8077
<div class="graph__graph-pane">
8178
${when(
82-
this.graphState.state.config?.minimap !== false,
79+
this.graphState.config?.minimap !== false,
8380
() => html`
8481
<gl-graph-minimap-container
8582
.activeDay=${this.graphState.activeDay}
86-
.disabled=${!this.graphState.state.config?.minimap}
87-
.rows=${this.graphState.state.rows ?? []}
88-
.rowsStats=${this.graphState.state.rowsStats}
89-
.dataType=${this.graphState.state.config?.minimapDataType ?? 'commits'}
90-
.markerTypes=${this.graphState.state.config?.minimapMarkerTypes ?? []}
91-
.refMetadata=${this.graphState.state.refsMetadata}
83+
.disabled=${!this.graphState.config?.minimap}
84+
.rows=${this.graphState.rows ?? []}
85+
.rowsStats=${this.graphState.rowsStats}
86+
.dataType=${this.graphState.config?.minimapDataType ?? 'commits'}
87+
.markerTypes=${this.graphState.config?.minimapMarkerTypes ?? []}
88+
.refMetadata=${this.graphState.refsMetadata}
9289
.searchResults=${this.graphState.searchResults}
9390
.visibleDays=${this.graphState.visibleDays}
9491
@gl-graph-minimap-selected=${this.handleMinimapDaySelected}
9592
></gl-graph-minimap-container>
9693
`,
9794
)}
98-
${when(
99-
this.graphState.state.config?.sidebar,
100-
() => html`<gl-graph-sidebar></gl-graph-sidebar>`,
101-
)}
95+
${when(this.graphState.config?.sidebar, () => html`<gl-graph-sidebar></gl-graph-sidebar>`)}
10296
<gl-graph-hover id="commit-hover" distance=${0} skidding=${15}></gl-graph-hover>
10397
<gl-graph-wrapper
10498
@gl-graph-change-selection=${this.handleGraphSelectionChanged}
@@ -121,15 +115,15 @@ export class GraphApp extends SignalWatcher(LitElement) {
121115
}
122116

123117
private handleMinimapDaySelected(e: CustomEvent<GraphMinimapDaySelectedEventDetail>) {
124-
if (!this.graphState.state.rows) return;
118+
if (!this.graphState.rows) return;
125119

126120
let { sha } = e.detail;
127121
if (sha == null) {
128122
const date = e.detail.date?.getTime();
129123
if (date == null) return;
130124

131125
// Find closest row to the date
132-
const closest = this.graphState.state.rows.reduce((prev, curr) => {
126+
const closest = this.graphState.rows.reduce((prev, curr) => {
133127
return Math.abs(curr.date - date) < Math.abs(prev.date - date) ? curr : prev;
134128
});
135129
sha = closest.sha;

0 commit comments

Comments
 (0)