From f5143e82168a9a022ce6bc9e5ea2ad21a1946a2c Mon Sep 17 00:00:00 2001 From: gearheaded Date: Sun, 21 Jun 2026 17:44:32 -0400 Subject: [PATCH] fix: bump minAppVersion, type API responses, fix unawaited promises --- main.js | 11 +++++++---- manifest.json | 4 ++-- package.json | 2 +- src/main.ts | 23 +++++++++++++++-------- versions.json | 3 ++- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/main.js b/main.js index 9aa5380..39d57e3 100644 --- a/main.js +++ b/main.js @@ -491,7 +491,7 @@ var ContributionsView = class extends import_obsidian.ItemView { if (Math.abs(w - this.panelWidth) > 5) { this.panelWidth = w; if (this.plugin.settings.sizePreset === "fit") - this.render(); + void this.render(); } }); this.resizeObserver.observe(this.containerEl); @@ -758,7 +758,9 @@ var ContributionsView = class extends import_obsidian.ItemView { if (this.tooltipEl) this.tooltipEl.setCssStyles({ display: "none" }); }); - cell.addEventListener("click", () => this.openOrCreateDailyNote(day.date)); + cell.addEventListener("click", () => { + void this.openOrCreateDailyNote(day.date); + }); } showTooltip(e, day) { if (!this.tooltipEl) @@ -1183,7 +1185,8 @@ var GitHubContributionsPlugin = class extends import_obsidian.Plugin { } } async loadSettings() { - this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); + const savedData = await this.loadData(); + this.settings = Object.assign({}, DEFAULT_SETTINGS, savedData != null ? savedData : {}); if (this.settings.selectedYear > new Date().getFullYear()) this.settings.selectedYear = new Date().getFullYear(); } @@ -1192,7 +1195,7 @@ var GitHubContributionsPlugin = class extends import_obsidian.Plugin { this.injectPaletteStyles(); this.app.workspace.getLeavesOfType(VIEW_TYPE).forEach((leaf) => { if (leaf.view instanceof ContributionsView) - leaf.view.refresh(); + void leaf.view.refresh(); }); } injectPaletteStyles() { diff --git a/manifest.json b/manifest.json index 0e2d6c0..36f14f2 100644 --- a/manifest.json +++ b/manifest.json @@ -1,8 +1,8 @@ { "id": "github-contributions", "name": "GitHub Contributions", - "version": "1.0.2", - "minAppVersion": "0.15.0", + "version": "1.0.3", + "minAppVersion": "1.0.0", "description": "View GitHub and local Git contributions directly in the sidebar with streak tracking, repository breakdowns, color palettes, and daily note integration.", "author": "gearheaded", "authorUrl": "https://github.com/gearheaded", diff --git a/package.json b/package.json index 2258dc8..a5a7cf3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-github-contributions", - "version": "1.0.2", + "version": "1.0.3", "description": "GitHub contribution graph for Obsidian", "main": "main.js", "scripts": { diff --git a/src/main.ts b/src/main.ts index 8e9b260..a55418d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -196,6 +196,12 @@ interface DeviceCodeResponse { // We use Obsidian's requestUrl (not fetch) because the device flow endpoint // doesn't have CORS headers, so direct fetch() calls from Obsidian's webview fail. // Returns the user_code to display, device_code to poll with, and expiry/interval. +interface TokenPollResponse { + access_token?: string; + error?: string; + error_description?: string; +} + async function requestDeviceCode(): Promise { let res; try { @@ -209,7 +215,7 @@ async function requestDeviceCode(): Promise { throw new Error("Could not reach GitHub. Check your internet connection."); } if (res.status !== 200) throw new Error(`GitHub returned an error (${res.status}). Try again.`); - return res.json; + return res.json as DeviceCodeResponse; } // Step 2 of OAuth device flow: poll GitHub until the user approves or the code expires. @@ -235,7 +241,7 @@ async function pollForToken( // Check if code has expired client-side before even polling if (Date.now() > deadline) throw new Error("Code expired. Please try again."); - let data: Record; + let data: TokenPollResponse; try { const res = await requestUrl({ url: GITHUB_TOKEN_URL, @@ -247,7 +253,7 @@ async function pollForToken( grant_type: "urn:ietf:params:oauth:grant-type:device_code", }), }); - data = res.json; + data = res.json as TokenPollResponse; } catch { // Network error - wait and retry rather than failing immediately await delay(5000); @@ -363,7 +369,7 @@ interface NodePathModule { join(...parts: string[]): string; } interface NodeChildProcessModule { - execSync(command: string, options: { cwd: string; timeout: number; encoding: string; stdio: string[] }): string; + execSync(this: void, command: string, options: { cwd: string; timeout: number; encoding: string; stdio: string[] }): string; } // The subset of the Electron renderer's window object we depend on. interface ElectronWindow { @@ -722,7 +728,7 @@ export class ContributionsView extends ItemView { const w = this.containerEl.clientWidth; if (Math.abs(w - this.panelWidth) > 5) { this.panelWidth = w; - if (this.plugin.settings.sizePreset === "fit") this.render(); + if (this.plugin.settings.sizePreset === "fit") void this.render(); } }); this.resizeObserver.observe(this.containerEl); @@ -1010,7 +1016,7 @@ export class ContributionsView extends ItemView { cell.addEventListener("mouseenter", (e: MouseEvent) => this.showTooltip(e, day)); cell.addEventListener("mouseleave", () => { if (this.tooltipEl) this.tooltipEl.setCssStyles({ display: "none" }); }); - cell.addEventListener("click", () => this.openOrCreateDailyNote(day.date)); + cell.addEventListener("click", () => { void this.openOrCreateDailyNote(day.date); }); } private showTooltip(e: MouseEvent, day: DayData) { @@ -1552,7 +1558,8 @@ export default class GitHubContributionsPlugin extends Plugin { } async loadSettings() { - this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()); + const savedData = (await this.loadData()) as Partial | null; + this.settings = Object.assign({}, DEFAULT_SETTINGS, savedData ?? {}); if (this.settings.selectedYear > new Date().getFullYear()) this.settings.selectedYear = new Date().getFullYear(); } @@ -1560,7 +1567,7 @@ export default class GitHubContributionsPlugin extends Plugin { await this.saveData(this.settings); this.injectPaletteStyles(); this.app.workspace.getLeavesOfType(VIEW_TYPE).forEach(leaf => { - if (leaf.view instanceof ContributionsView) leaf.view.refresh(); + if (leaf.view instanceof ContributionsView) void leaf.view.refresh(); }); } diff --git a/versions.json b/versions.json index b7018d5..c961191 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,6 @@ { "1.0.0": "0.15.0", "1.0.1": "0.15.0", - "1.0.2": "0.15.0" + "1.0.2": "0.15.0", + "1.0.3": "1.0.0" } \ No newline at end of file