Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 revert dirty event in client #68

Merged
merged 7 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@juzi/wechaty-puppet-service",
"version": "1.0.87",
"version": "1.0.88",
"description": "Puppet Service for Wechaty",
"type": "module",
"exports": {
Expand Down
17 changes: 9 additions & 8 deletions src/client/puppet-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@
}
break
case grpcPuppet.EventType.EVENT_TYPE_DIRTY:
await this.fastDirty(JSON.parse(payload))
this.emit('dirty', JSON.parse(payload) as PUPPET.payloads.EventDirty)
break
case grpcPuppet.EventType.EVENT_TYPE_MESSAGE:
Expand Down Expand Up @@ -449,13 +448,13 @@
* `onDirty()` is called when the puppet emit `dirty` event.
* the event listener will be registered in `start()` from the `PuppetAbstract` class
*/
async fastDirty (
override onDirty (
{
payloadType,
payloadId,
}: PUPPET.payloads.EventDirty,
): Promise<void> {

Check failure on line 456 in src/client/puppet-service.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 16)

A function whose declared type is neither 'void' nor 'any' must return a value.

Check failure on line 456 in src/client/puppet-service.ts

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, 16)

A function whose declared type is neither 'void' nor 'any' must return a value.
log.verbose('PuppetService', 'fastDirty(%s<%s>, %s)', PUPPET.types.Dirty[payloadType], payloadType, payloadId)
log.verbose('PuppetService', 'onDirty(%s<%s>, %s)', PUPPET.types.Dirty[payloadType], payloadType, payloadId)

const dirtyMap = {
[PUPPET.types.Dirty.Contact]: async (id: string) => this._payloadStore.contact?.delete(id),
Expand All @@ -469,11 +468,13 @@
[PUPPET.types.Dirty.Unspecified]: async (id: string) => { throw new Error('Unspecified type with id: ' + id) },
}

try {
await dirtyMap[payloadType](payloadId)
} catch (error) {
this.emit('error', error)
}
const dirtyFuncSync = this.wrapAsync(dirtyMap[payloadType])
dirtyFuncSync(payloadId)

/**
* We need to call `super.onDirty()` to clean the `PuppetAbstract` LRUCache
*/
super.onDirty({ payloadId, payloadType })
}

override async enterVerifyCode (id: string, code: string): Promise<void> {
Expand Down
Loading