Skip to content

Commit

Permalink
Small adjustments to code based on Obsidian Team's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmcgivery committed Jan 31, 2024
1 parent 731c474 commit 3089c5a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 37 deletions.
29 changes: 15 additions & 14 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { App, Plugin, PluginSettingTab, Setting, getIcon } from "obsidian";
import debounce from "./utils/debounce";
import {
App,
Plugin,
PluginSettingTab,
Setting,
debounce,
setIcon,
} from "obsidian";

interface Soundscape {
id: string;
Expand Down Expand Up @@ -147,7 +153,7 @@ export default class SoundscapesPlugin extends Plugin {

async onload() {
await this.loadSettings();
this.debouncedSaveSettings = debounce(this.saveSettings, 500);
this.debouncedSaveSettings = debounce(this.saveSettings, 500, true);

this.statusBarItem = this.addStatusBarItem();
this.statusBarItem.addClass("soundscapesroot");
Expand Down Expand Up @@ -234,14 +240,8 @@ export default class SoundscapesPlugin extends Plugin {
* Create all the UI elements
*/
createControls() {
const playIcon = getIcon("play") as Node;
const pauseIcon = getIcon("pause") as Node;
const volumeLowIcon = getIcon("volume-1") as Node;
const volumeHighIcon = getIcon("volume-2") as Node;
const volumeMuteIcon = getIcon("volume-x") as Node;

this.playButton = this.statusBarItem.createEl("button", {});
this.playButton.appendChild(playIcon);
setIcon(this.playButton, "play");
this.playButton.onclick = () => {
// When it's a live video, attempt to jump to the "live" portion
if (SOUNDSCAPES[this.settings.soundscape].isLiveVideo) {
Expand All @@ -251,7 +251,7 @@ export default class SoundscapesPlugin extends Plugin {
};

this.pauseButton = this.statusBarItem.createEl("button", {});
this.pauseButton.appendChild(pauseIcon);
setIcon(this.pauseButton, "pause");
this.pauseButton.onclick = () => this.player.pauseVideo();

this.nowPlaying = this.statusBarItem.createEl("div", {
Expand All @@ -265,17 +265,17 @@ export default class SoundscapesPlugin extends Plugin {
this.volumeMutedIcon = volumeIcons.createEl("div", {
cls: "soundscapesroot-volumeIcons-iconmuted",
});
this.volumeMutedIcon.appendChild(volumeMuteIcon);
setIcon(this.volumeMutedIcon, "volume-x");

this.volumeLowIcon = volumeIcons.createEl("div", {
cls: "soundscapesroot-volumeIcons-iconlow",
});
this.volumeLowIcon.appendChild(volumeLowIcon);
setIcon(this.volumeLowIcon, "volume-1");

this.volumeHighIcon = volumeIcons.createEl("div", {
cls: "soundscapesroot-volumeIcons-iconhigh",
});
this.volumeHighIcon.appendChild(volumeHighIcon);
setIcon(this.volumeHighIcon, "volume-2");

this.volumeSlider = this.statusBarItem.createEl("input", {
attr: {
Expand Down Expand Up @@ -346,6 +346,7 @@ export default class SoundscapesPlugin extends Plugin {
* Save data to disk, stored in data.json in plugin folder
*/
async saveSettings() {
console.log("saving...");
await this.saveData(this.settings);
}
}
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"id": "soundscapes",
"name": "Soundscapes",
"version": "1.0.0",
"version": "1.0.1",
"minAppVersion": "0.15.0",
"description": "Adds a music/ambiance (E.g. lofi, white noise) player to the status bar to help with concentration.",
"author": "Andrew McGivery",
"authorUrl": "https://github.com/andrewmcgivery",
"fundingUrl": "https://www.buymeacoffee.com/andrewmcgivery",
"isDesktopOnly": true
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-soundscapes",
"version": "1.0.0",
"version": "1.0.1",
"description": "A plugin for Obsidian.MD that adds a music/ambiance player to the status bar.",
"main": "dist/main.js",
"scripts": {
Expand Down
18 changes: 0 additions & 18 deletions utils/debounce.ts

This file was deleted.

5 changes: 3 additions & 2 deletions versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"1.0.0": "0.15.0"
}
"1.0.0": "0.15.0",
"1.0.1": "0.15.0"
}

0 comments on commit 3089c5a

Please sign in to comment.