refactor: write lastVisited and query at the same time

In addition, the `settings.write` method now uses shallow merge by default
This commit is contained in:
futengda
2020-07-31 11:39:37 +08:00
parent b6e791f7d0
commit ecb9bb2428
2 changed files with 5 additions and 10 deletions

View File

@ -30,9 +30,9 @@ export class SettingsProvider<T> {
/**
* Write settings combined with current settings. On failure log a warning.
* Objects will be merged and everything else will be replaced.
* Settings can be shallow or deep merged.
*/
public async write(settings: Partial<T>, shallow?: boolean): Promise<void> {
public async write(settings: Partial<T>, shallow = true): Promise<void> {
try {
const oldSettings = await this.read()
const nextSettings = shallow ? Object.assign({}, oldSettings, settings) : extend(oldSettings, settings)