Skip to content

Commit

Permalink
🐛 修复调试脚本时getValue获取旧值
Browse files Browse the repository at this point in the history
  • Loading branch information
joriscai authored Mar 1, 2022
1 parent d0c664f commit 75215e3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/apps/script/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,16 @@ export class ScriptController {
});
}

public saveValue(script: Script, key: string, val: any): Promise<Value | undefined> {
return this.updateValue(key, val, script.id, (script.metadata['storagename'] && script.metadata['storagename'][0] || undefined));
public async saveValue(script: Script, key: string, val: any): Promise<Value | undefined> {
const storageName = script.metadata?.storagename?.[0]
// 无缓存字段时
if (!storageName) {
return
}
const model = await this.updateValue(key, val, script.id, storageName);
// 清空storagename的缓存数据,触发getScriptValue方法重新同步一次数据
await App.Cache.remove('value:storagename:' + storageName)
return model
}

public deleteValue(script: Script, key: string): Promise<void> {
Expand Down

1 comment on commit 75215e3

@unrival7j112
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

哥哥牛逼

Please sign in to comment.