Skip to content

Commit

Permalink
fix(webui): fix webui meta error
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 3, 2021
1 parent f705a03 commit 4c84f33
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-eval/tests/worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-new-wrappers */

import { internal } from 'koishi-plugin-eval/dist/worker'
import { internal } from 'koishi-plugin-eval/lib/worker'

internal.setGlobal('test', {
null: null,
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-teach/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"node": ">=12.0.0"
},
"files": [
"lib"
"lib",
"dist"
],
"author": "Shigma <1700011071@pku.edu.cn>",
"license": "MIT",
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-webui/src/data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Argv, Assets, Bot, Context, Platform, Plugin, Time } from 'koishi-core'
import { Argv, Assets, Bot, Context, Platform, Plugin, Time, noop } from 'koishi-core'
import { cpus } from 'os'
import { mem } from 'systeminformation'

Expand Down Expand Up @@ -142,8 +142,8 @@ export class Meta implements DataSource<Meta.Payload> {
callbacks: Meta.Extension[] = []

constructor(private ctx: Context, public config: Meta.Config) {
this.extend(() => ctx.assets?.stats())
this.extend(() => ctx.database?.getStats())
this.extend(async () => ctx.assets?.stats())
this.extend(async () => ctx.database.getStats())

ctx.all().on('command', ({ session }: Argv<'lastCall'>) => {
session.user.lastCall = new Date()
Expand All @@ -155,7 +155,7 @@ export class Meta implements DataSource<Meta.Payload> {
if (this.timestamp > now) return this.cachedMeta
this.timestamp = now + Time.hour
return this.cachedMeta = Promise
.all(this.callbacks.map(cb => cb().catch(() => ({}))))
.all(this.callbacks.map(cb => cb().catch(noop)))
.then(data => Object.assign({}, ...data))
}

Expand Down

0 comments on commit 4c84f33

Please sign in to comment.