Skip to content

Commit

Permalink
Merge pull request #49 from ww24/fix/restore-default-settings
Browse files Browse the repository at this point in the history
fix(settings): fix restore default settings
  • Loading branch information
ww24 authored Jun 30, 2024
2 parents 94c59b5 + 338acdf commit 2efe658
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export class Configuration {
this.updatedAt = 0
this.userId = ''
}
static restoreDefault({ userId }: Configuration): Configuration {
const config = new Configuration()
return { ...config, userId }
}
static videoFormat(config: Configuration): VideoFormat {
if (config.videoFormat.videoBitrate === 0) {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/element/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class Settings extends LitElement {
}
private async restore() {
const oldVal = this.config
this.config = new Configuration()
this.config = Configuration.restoreDefault(this.config)
this.requestUpdate('config', oldVal)
this.resetValidityError()
Settings.setConfiguration(this.config)
Expand Down
1 change: 1 addition & 0 deletions src/service_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ chrome.runtime.onInstalled.addListener(async () => {
if (config.userId === '') {
config.userId = uuidv7()
}
await storage.set(Configuration.key, config)
console.debug('config:', config)

const msg: OffscreenSyncConfigMessage = {
Expand Down

0 comments on commit 2efe658

Please sign in to comment.