Skip to content

Commit

Permalink
fix: linting, bump
Browse files Browse the repository at this point in the history
  • Loading branch information
studiowebux committed Oct 15, 2024
1 parent 3dcd0ae commit 9bd63db
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
27 changes: 20 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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);

Expand All @@ -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) {
Expand All @@ -107,8 +120,8 @@ export default class SpotifyLinkPlugin extends Plugin {
"spotify",
'<path fill="currentColor" d="M 52.021502,2.019 C 24.520376,2.019 2.019,24.520376 2.019,52.021502 2.019,79.517624 24.520376,102.019 52.021502,102.019 79.517624,102.019 102.019,79.517624 102.019,52.021502 102.019,24.520376 79.767861,2.019 52.021502,2.019 Z m 22.996847,72.248636 c -0.995946,1.496422 -2.74761,2.001902 -4.254041,1.005956 -11.756168,-7.256894 -26.50518,-8.758321 -44.006806,-4.759522 -1.741655,0.510485 -3.243081,-0.740703 -3.743557,-2.247134 -0.50548,-1.751665 0.745709,-3.243081 2.25214,-3.748562 18.993043,-4.254041 35.498724,-2.497372 48.496071,5.50523 1.751664,0.745709 2.001902,2.742606 1.256193,4.244032 z m 6.005706,-13.74806 c -1.256194,1.746659 -3.503328,2.497372 -5.259997,1.246183 -13.497823,-8.237826 -33.992293,-10.750212 -49.742255,-5.745458 -1.991893,0.50548 -4.254042,-0.500475 -4.749512,-2.492368 -0.505481,-2.011911 0.500475,-4.26405 2.497372,-4.764526 18.247335,-5.49522 40.753716,-2.742605 56.248436,6.761424 1.501426,0.745708 2.25214,3.24308 1.005956,4.994745 z m 0.49547,-14.008308 C 65.519325,37.017248 38.768912,36.016297 23.514421,40.775819 a 4.6944597,4.6944597 0 0 1 -5.745459,-3.002853 4.689455,4.689455 0 0 1 2.997848,-5.760472 c 17.751865,-5.249988 47.004655,-4.254042 65.507232,6.761423 2.247135,1.246184 2.997848,4.249037 1.74666,6.496172 -1.251189,1.751664 -4.249037,2.492367 -6.501177,1.241179 z" style="stroke-width:5.00475" />',
);
this.addRibbonIcon("spotify", "Connect Spotify", async () => {
await onLogin(
this.addRibbonIcon("spotify", "Connect Spotify", () => {
onLogin(
this.settings.spotifyClientId,
this.settings.spotifyState,
this.settings.spotifyScopes,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type SpotifyLinkSettings = {
spotifyScopes: string;
spotifyState: string;
templates: string[];
menu: Array<Record<{ name: string; enabled: boolean }>>;
menu: Array<{ name: string; enabled: boolean; id: string }>;
defaultDestination: string;
overwrite: boolean;
};
Expand Down

0 comments on commit 9bd63db

Please sign in to comment.