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" ;
3
9
4
10
interface Soundscape {
5
11
id : string ;
@@ -147,7 +153,7 @@ export default class SoundscapesPlugin extends Plugin {
147
153
148
154
async onload ( ) {
149
155
await this . loadSettings ( ) ;
150
- this . debouncedSaveSettings = debounce ( this . saveSettings , 500 ) ;
156
+ this . debouncedSaveSettings = debounce ( this . saveSettings , 500 , true ) ;
151
157
152
158
this . statusBarItem = this . addStatusBarItem ( ) ;
153
159
this . statusBarItem . addClass ( "soundscapesroot" ) ;
@@ -234,14 +240,8 @@ export default class SoundscapesPlugin extends Plugin {
234
240
* Create all the UI elements
235
241
*/
236
242
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
-
243
243
this . playButton = this . statusBarItem . createEl ( "button" , { } ) ;
244
- this . playButton . appendChild ( playIcon ) ;
244
+ setIcon ( this . playButton , "play" ) ;
245
245
this . playButton . onclick = ( ) => {
246
246
// When it's a live video, attempt to jump to the "live" portion
247
247
if ( SOUNDSCAPES [ this . settings . soundscape ] . isLiveVideo ) {
@@ -251,7 +251,7 @@ export default class SoundscapesPlugin extends Plugin {
251
251
} ;
252
252
253
253
this . pauseButton = this . statusBarItem . createEl ( "button" , { } ) ;
254
- this . pauseButton . appendChild ( pauseIcon ) ;
254
+ setIcon ( this . pauseButton , "pause" ) ;
255
255
this . pauseButton . onclick = ( ) => this . player . pauseVideo ( ) ;
256
256
257
257
this . nowPlaying = this . statusBarItem . createEl ( "div" , {
@@ -265,17 +265,17 @@ export default class SoundscapesPlugin extends Plugin {
265
265
this . volumeMutedIcon = volumeIcons . createEl ( "div" , {
266
266
cls : "soundscapesroot-volumeIcons-iconmuted" ,
267
267
} ) ;
268
- this . volumeMutedIcon . appendChild ( volumeMuteIcon ) ;
268
+ setIcon ( this . volumeMutedIcon , "volume-x" ) ;
269
269
270
270
this . volumeLowIcon = volumeIcons . createEl ( "div" , {
271
271
cls : "soundscapesroot-volumeIcons-iconlow" ,
272
272
} ) ;
273
- this . volumeLowIcon . appendChild ( volumeLowIcon ) ;
273
+ setIcon ( this . volumeLowIcon , "volume-1" ) ;
274
274
275
275
this . volumeHighIcon = volumeIcons . createEl ( "div" , {
276
276
cls : "soundscapesroot-volumeIcons-iconhigh" ,
277
277
} ) ;
278
- this . volumeHighIcon . appendChild ( volumeHighIcon ) ;
278
+ setIcon ( this . volumeHighIcon , "volume-2" ) ;
279
279
280
280
this . volumeSlider = this . statusBarItem . createEl ( "input" , {
281
281
attr : {
@@ -346,6 +346,7 @@ export default class SoundscapesPlugin extends Plugin {
346
346
* Save data to disk, stored in data.json in plugin folder
347
347
*/
348
348
async saveSettings ( ) {
349
+ console . log ( "saving..." ) ;
349
350
await this . saveData ( this . settings ) ;
350
351
}
351
352
}
0 commit comments