all: fix formatting
diff --git a/webui/src/web-components/sketch-diff-range-picker.ts b/webui/src/web-components/sketch-diff-range-picker.ts
index 38d29b0..aebe6ff 100644
--- a/webui/src/web-components/sketch-diff-range-picker.ts
+++ b/webui/src/web-components/sketch-diff-range-picker.ts
@@ -170,14 +170,14 @@
setTimeout(() => this.loadCommits(), 0); // Give time for provider initialization
});
}
-
+
// Listen for popstate events to handle browser back/forward navigation
- window.addEventListener('popstate', this.handlePopState.bind(this));
+ window.addEventListener("popstate", this.handlePopState.bind(this));
}
disconnectedCallback() {
super.disconnectedCallback();
- window.removeEventListener('popstate', this.handlePopState.bind(this));
+ window.removeEventListener("popstate", this.handlePopState.bind(this));
}
/**
@@ -354,7 +354,7 @@
// Check if we should initialize from URL parameters first
const initializedFromUrl = this.initializeFromUrlParams();
-
+
// Set default selections only if not initialized from URL
if (this.commits.length > 0 && !initializedFromUrl) {
// For range, default is base to HEAD
@@ -373,7 +373,7 @@
// For single, default to HEAD
this.singleCommit = this.commits[0].hash;
}
-
+
// Always dispatch range event to ensure diff view is updated
this.dispatchRangeEvent();
} catch (error) {
@@ -389,10 +389,13 @@
*/
setRangeType(type: "range" | "single") {
this.rangeType = type;
-
+
// If switching to range mode and we don't have valid commits set,
// initialize with sensible defaults
- if (type === 'range' && (!this.fromCommit || !this.toCommit === undefined)) {
+ if (
+ type === "range" &&
+ (!this.fromCommit || !this.toCommit === undefined)
+ ) {
if (this.commits.length > 0) {
const baseCommit = this.commits.find(
(c) => c.refs && c.refs.some((ref) => ref.includes("sketch-base")),
@@ -403,17 +406,17 @@
: this.commits[this.commits.length - 1].hash;
}
if (this.toCommit === undefined) {
- this.toCommit = ''; // Default to uncommitted changes
+ this.toCommit = ""; // Default to uncommitted changes
}
}
}
-
+
// If switching to single mode and we don't have a valid commit set,
// initialize with HEAD
- if (type === 'single' && !this.singleCommit && this.commits.length > 0) {
+ if (type === "single" && !this.singleCommit && this.commits.length > 0) {
this.singleCommit = this.commits[0].hash;
}
-
+
this.dispatchRangeEvent();
}
@@ -455,8 +458,10 @@
* Validate that a commit hash exists in the loaded commits
*/
private isValidCommitHash(hash: string): boolean {
- if (!hash || hash.trim() === '') return true; // Empty is valid (uncommitted changes)
- return this.commits.some(commit => commit.hash.startsWith(hash) || commit.hash === hash);
+ if (!hash || hash.trim() === "") return true; // Empty is valid (uncommitted changes)
+ return this.commits.some(
+ (commit) => commit.hash.startsWith(hash) || commit.hash === hash,
+ );
}
/**
@@ -485,30 +490,30 @@
*/
private updateUrlParams(range: DiffRange) {
const url = new URL(window.location.href);
-
+
// Remove existing range parameters
- url.searchParams.delete('from');
- url.searchParams.delete('to');
- url.searchParams.delete('commit');
-
- if (range.type === 'range') {
+ url.searchParams.delete("from");
+ url.searchParams.delete("to");
+ url.searchParams.delete("commit");
+
+ if (range.type === "range") {
// Add from parameter if not empty
- if (range.from && range.from.trim() !== '') {
- url.searchParams.set('from', range.from);
+ if (range.from && range.from.trim() !== "") {
+ url.searchParams.set("from", range.from);
}
// Add to parameter if not empty (empty string means uncommitted changes)
- if (range.to && range.to.trim() !== '') {
- url.searchParams.set('to', range.to);
+ if (range.to && range.to.trim() !== "") {
+ url.searchParams.set("to", range.to);
}
} else {
// Single commit mode
- if (range.commit && range.commit.trim() !== '') {
- url.searchParams.set('commit', range.commit);
+ if (range.commit && range.commit.trim() !== "") {
+ url.searchParams.set("commit", range.commit);
}
}
-
+
// Update the browser history without reloading the page
- window.history.replaceState(window.history.state, '', url.toString());
+ window.history.replaceState(window.history.state, "", url.toString());
}
/**
@@ -516,20 +521,20 @@
*/
private initializeFromUrlParams() {
const url = new URL(window.location.href);
- const fromParam = url.searchParams.get('from');
- const toParam = url.searchParams.get('to');
- const commitParam = url.searchParams.get('commit');
-
+ const fromParam = url.searchParams.get("from");
+ const toParam = url.searchParams.get("to");
+ const commitParam = url.searchParams.get("commit");
+
// If commit parameter is present, switch to single commit mode
if (commitParam) {
- this.rangeType = 'single';
+ this.rangeType = "single";
this.singleCommit = commitParam;
return true; // Indicate that we initialized from URL
}
-
+
// If from or to parameters are present, use range mode
if (fromParam || toParam) {
- this.rangeType = 'range';
+ this.rangeType = "range";
if (fromParam) {
this.fromCommit = fromParam;
}
@@ -537,11 +542,11 @@
this.toCommit = toParam;
} else {
// If no 'to' param, default to uncommitted changes (empty string)
- this.toCommit = '';
+ this.toCommit = "";
}
return true; // Indicate that we initialized from URL
}
-
+
return false; // No URL params found
}
}