From 9bd63db9b5e649c346c2f1aabf77045621b6ef92 Mon Sep 17 00:00:00 2001 From: tommy gingras Date: Tue, 15 Oct 2024 18:42:38 -0400 Subject: [PATCH] fix: linting, bump --- manifest.json | 2 +- package.json | 2 +- src/main.ts | 27 ++++++++++++++++++++------- src/types.ts | 2 +- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/manifest.json b/manifest.json index 4d38bc5..3dcc483 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "spotify-link", "name": "Spotify Link", - "version": "1.5.0", + "version": "1.5.1", "minAppVersion": "0.15.0", "description": "Include the song you're currently listening to in your note.", "author": "Studio Webux", diff --git a/package.json b/package.json index 664c982..9a061c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "spotify-link", - "version": "1.5.0", + "version": "1.5.1", "description": "Include the song you're currently listening to in your Obsidian (https://obsidian.md) note", "main": "main.js", "scripts": { diff --git a/src/main.ts b/src/main.ts index 8801d08..50694e8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,18 @@ -import { Editor, Notice, Plugin, addIcon, normalizePath } from "obsidian"; -import { SpotifyLinkSettings, SpotifyAuthCallback } from "./types"; +import { + Editor, + Menu, + MenuItem, + Notice, + Plugin, + TFile, + addIcon, + normalizePath, +} from "obsidian"; +import { + SpotifyLinkSettings, + SpotifyAuthCallback, + CurrentlyPlayingTrack, +} from "./types"; import { getSpotifyUrl, handleCallback, requestRefreshToken } from "./api"; import SettingsTab from "./settingsTab"; import { handleEditor, handleTemplateEditor } from "./ui"; @@ -38,7 +51,7 @@ export default class SpotifyLinkPlugin extends Plugin { async createFile(parent: string, id: string) { let content = ""; - let track: CurrentlyPlayingTrack | null = null; + let track: CurrentlyPlayingTrack | string | null = null; let template_index = -1; if ( @@ -70,7 +83,7 @@ export default class SpotifyLinkPlugin extends Plugin { } const filename = `${normalizePath( - `/${parent}/${track?.item?.name ?? new Date().toISOString()}`, + `/${parent}/${(track as CurrentlyPlayingTrack)?.item?.name ?? new Date().toISOString()}`, ).replace(/[:|.]/g, "_")}.md`; const exists = await this.app.vault.adapter.exists(filename, true); @@ -80,7 +93,7 @@ export default class SpotifyLinkPlugin extends Plugin { if (this.settings.overwrite === true) { try { await this.app.vault.modify( - this.app.vault.getFileByPath(filename), + this.app.vault.getAbstractFileByPath(filename) as TFile, content, ); if (exists) { @@ -107,8 +120,8 @@ export default class SpotifyLinkPlugin extends Plugin { "spotify", '', ); - this.addRibbonIcon("spotify", "Connect Spotify", async () => { - await onLogin( + this.addRibbonIcon("spotify", "Connect Spotify", () => { + onLogin( this.settings.spotifyClientId, this.settings.spotifyState, this.settings.spotifyScopes, diff --git a/src/types.ts b/src/types.ts index a56b147..6363ef8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -7,7 +7,7 @@ export type SpotifyLinkSettings = { spotifyScopes: string; spotifyState: string; templates: string[]; - menu: Array>; + menu: Array<{ name: string; enabled: boolean; id: string }>; defaultDestination: string; overwrite: boolean; };