Skip to content

Commit 3089c5a

Browse files
Small adjustments to code based on Obsidian Team's feedback
1 parent 731c474 commit 3089c5a

File tree

5 files changed

+21
-37
lines changed

5 files changed

+21
-37
lines changed

main.ts

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
import { App, Plugin, PluginSettingTab, Setting, getIcon } from "obsidian";
2-
import debounce from "./utils/debounce";
1+
import {
2+
App,
3+
Plugin,
4+
PluginSettingTab,
5+
Setting,
6+
debounce,
7+
setIcon,
8+
} from "obsidian";
39

410
interface Soundscape {
511
id: string;
@@ -147,7 +153,7 @@ export default class SoundscapesPlugin extends Plugin {
147153

148154
async onload() {
149155
await this.loadSettings();
150-
this.debouncedSaveSettings = debounce(this.saveSettings, 500);
156+
this.debouncedSaveSettings = debounce(this.saveSettings, 500, true);
151157

152158
this.statusBarItem = this.addStatusBarItem();
153159
this.statusBarItem.addClass("soundscapesroot");
@@ -234,14 +240,8 @@ export default class SoundscapesPlugin extends Plugin {
234240
* Create all the UI elements
235241
*/
236242
createControls() {
237-
const playIcon = getIcon("play") as Node;
238-
const pauseIcon = getIcon("pause") as Node;
239-
const volumeLowIcon = getIcon("volume-1") as Node;
240-
const volumeHighIcon = getIcon("volume-2") as Node;
241-
const volumeMuteIcon = getIcon("volume-x") as Node;
242-
243243
this.playButton = this.statusBarItem.createEl("button", {});
244-
this.playButton.appendChild(playIcon);
244+
setIcon(this.playButton, "play");
245245
this.playButton.onclick = () => {
246246
// When it's a live video, attempt to jump to the "live" portion
247247
if (SOUNDSCAPES[this.settings.soundscape].isLiveVideo) {
@@ -251,7 +251,7 @@ export default class SoundscapesPlugin extends Plugin {
251251
};
252252

253253
this.pauseButton = this.statusBarItem.createEl("button", {});
254-
this.pauseButton.appendChild(pauseIcon);
254+
setIcon(this.pauseButton, "pause");
255255
this.pauseButton.onclick = () => this.player.pauseVideo();
256256

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

270270
this.volumeLowIcon = volumeIcons.createEl("div", {
271271
cls: "soundscapesroot-volumeIcons-iconlow",
272272
});
273-
this.volumeLowIcon.appendChild(volumeLowIcon);
273+
setIcon(this.volumeLowIcon, "volume-1");
274274

275275
this.volumeHighIcon = volumeIcons.createEl("div", {
276276
cls: "soundscapesroot-volumeIcons-iconhigh",
277277
});
278-
this.volumeHighIcon.appendChild(volumeHighIcon);
278+
setIcon(this.volumeHighIcon, "volume-2");
279279

280280
this.volumeSlider = this.statusBarItem.createEl("input", {
281281
attr: {
@@ -346,6 +346,7 @@ export default class SoundscapesPlugin extends Plugin {
346346
* Save data to disk, stored in data.json in plugin folder
347347
*/
348348
async saveSettings() {
349+
console.log("saving...");
349350
await this.saveData(this.settings);
350351
}
351352
}

manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"id": "soundscapes",
33
"name": "Soundscapes",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"minAppVersion": "0.15.0",
66
"description": "Adds a music/ambiance (E.g. lofi, white noise) player to the status bar to help with concentration.",
77
"author": "Andrew McGivery",
88
"authorUrl": "https://github.com/andrewmcgivery",
99
"fundingUrl": "https://www.buymeacoffee.com/andrewmcgivery",
1010
"isDesktopOnly": true
11-
}
11+
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-soundscapes",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "A plugin for Obsidian.MD that adds a music/ambiance player to the status bar.",
55
"main": "dist/main.js",
66
"scripts": {

utils/debounce.ts

-18
This file was deleted.

versions.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"1.0.0": "0.15.0"
3-
}
2+
"1.0.0": "0.15.0",
3+
"1.0.1": "0.15.0"
4+
}

0 commit comments

Comments
 (0)