Skip to content

Commit d1e1e0c

Browse files
committed
fix(switchInfo): fix inconsistent states of switchInfo
1 parent 18bce08 commit d1e1e0c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/guide/common/switchInfo/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ export class SwitchInfo {
4747
</div>
4848
`;
4949
this.divElement.querySelector('.right').addEventListener('click', async (ev: MouseEvent) => {
50+
this.options.on = !this.options.on
5051
const newConfig = await getCoreConfig()
51-
newConfig[this.options.key] = !this.options.on
52-
setCoreConfig(newConfig)
53-
message.send('refresh-config')
54-
window.dispatchEvent(new Event("refresh"))
52+
newConfig[this.options.key] = this.options.on
53+
setCoreConfig(newConfig).then(() => { message.send('refresh-config') })
5554
})
5655
}
5756
}

src/option/common/switchInfo/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ export class SwitchInfo {
4747
</div>
4848
`;
4949
this.divElement.querySelector('.right input').addEventListener('click', async (ev: MouseEvent) => {
50+
this.options.on = !this.options.on
5051
const newConfig = await getCoreConfig()
51-
newConfig[this.options.key] = !this.options.on
52+
newConfig[this.options.key] = this.options.on
5253
setCoreConfig(newConfig).then(() => message.send('refresh-config'))
5354
})
5455
}

0 commit comments

Comments
 (0)