Skip to content

Commit

Permalink
Merge pull request #33 from cloudoptlab/fix/2.x/fix-switch-inconsiste…
Browse files Browse the repository at this point in the history
…nt-states

fix(switchInfo): fix inconsistent states of switchInfo
  • Loading branch information
T-baby committed Feb 16, 2020
2 parents 9550518 + d1e1e0c commit 7b84ced
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/guide/common/switchInfo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ export class SwitchInfo {
</div>
`;
this.divElement.querySelector('.right').addEventListener('click', async (ev: MouseEvent) => {
this.options.on = !this.options.on
const newConfig = await getCoreConfig()
newConfig[this.options.key] = !this.options.on
setCoreConfig(newConfig)
message.send('refresh-config')
window.dispatchEvent(new Event("refresh"))
newConfig[this.options.key] = this.options.on
setCoreConfig(newConfig).then(() => { message.send('refresh-config') })
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/option/common/switchInfo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ export class SwitchInfo {
</div>
`;
this.divElement.querySelector('.right input').addEventListener('click', async (ev: MouseEvent) => {
this.options.on = !this.options.on
const newConfig = await getCoreConfig()
newConfig[this.options.key] = !this.options.on
newConfig[this.options.key] = this.options.on
setCoreConfig(newConfig).then(() => message.send('refresh-config'))
})
}
Expand Down

0 comments on commit 7b84ced

Please sign in to comment.