Skip to content

Commit

Permalink
release 1.0.5
Browse files Browse the repository at this point in the history
fix: save user settings
  • Loading branch information
eatgrass committed Dec 13, 2023
1 parent b19e9fc commit c6a5409
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "lyrics",
"name": "Lyrics",
"version": "1.0.4",
"version": "1.0.5",
"minAppVersion": "0.15.0",
"description": "Enhance the audio player with interacive lyrics",
"author": "eatgrass",
Expand Down
16 changes: 8 additions & 8 deletions src/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export default class LyricsSettings extends PluginSettingTab {
this.settings = settings
}

public updateSettings(newSettings: Partial<Settings>) {
this.settings = { ...DEFAULT_SETTINGS, ...newSettings }
this.plugin.saveData(this.settings)
public async updateSettings(newSettings: Partial<Settings>) {
this.settings = { ...this.settings, ...newSettings }
await this.plugin.saveData(this.settings)
}

public display() {
Expand All @@ -40,14 +40,14 @@ export default class LyricsSettings extends PluginSettingTab {
})

new Setting(containerEl)
.setName('Sentence mode')
.setDesc('Whether enable sentence mode by default')
.addToggle((toggle)=> {
.setName('Sentence mode')
.setDesc('Whether enable sentence mode by default')
.addToggle((toggle) => {
toggle.setValue(this.settings.sentenceMode)
toggle.onChange((value) => {
this.updateSettings({sentenceMode: value })
this.updateSettings({ sentenceMode: value })
})
})
})
}

public getSettings(): Settings {
Expand Down
9 changes: 3 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import LyricsMarkdownRender from 'LyricsMarkdownRender'
import LyricsSettings, { DEFAULT_SETTINGS, type Settings } from 'Settings'
import {
Plugin,
type MarkdownPostProcessorContext,
} from 'obsidian'
import { Plugin, type MarkdownPostProcessorContext } from 'obsidian'

export default class LyricsPlugin extends Plugin {
private settings?: LyricsSettings
Expand All @@ -12,8 +9,8 @@ export default class LyricsPlugin extends Plugin {
return this.settings?.getSettings() || DEFAULT_SETTINGS
}

async onload() {
const settings = await this.loadData()
async onload() {
const settings = {...DEFAULT_SETTINGS, ...await this.loadData()}
this.settings = new LyricsSettings(this, settings)
this.addSettingTab(this.settings)

Expand Down

0 comments on commit c6a5409

Please sign in to comment.