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

add interface to provide update user info #15

Merged
merged 7 commits into from
Aug 6, 2018
Merged

add interface to provide update user info #15

merged 7 commits into from
Aug 6, 2018

Conversation

windmemory
Copy link
Member

No description provided.

Copy link
Member

@huan huan left a comment

Choose a reason for hiding this comment

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

Please be consistent and follow the old style, unless you have enough reason to change them, then you need to explain it in details.

@@ -69,6 +69,9 @@ class PuppetTest extends Puppet {
public async contactList () : Promise<string[]> { return {} as any }
public async contactQrcode (contactId: string) : Promise<string> { return { contactId } as any }

public async contactSelfName (newName: string) : Promise<boolean> { return true }
Copy link
Member

Choose a reason for hiding this comment

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

We should follow the current naming style, like we used contactQrcode instead of contactSelfQrcode

Copy link
Member Author

Choose a reason for hiding this comment

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

I would argue on this issue. Since getting qrcode, modifying name or signature, these operations are only allowed to be done on ContactSelf, so it makes sense to have self inside of the function name to indicate that this function is only related to self, not every contact. Does this make sense to you?

Copy link
Member

Choose a reason for hiding this comment

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

If they are ONLY allowed to be done on Self, why we need to point this out again?

Copy link
Member Author

@windmemory windmemory Aug 6, 2018

Choose a reason for hiding this comment

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

When we do coding ourselves, or some other contributors who do not familiar with the logic in wechaty, people will make mistake on that, so name it more specifically could avoid unnecessary mistake. Also save your time for explaining how the function works to the ones who don't know the logic.

@@ -69,6 +69,9 @@ class PuppetTest extends Puppet {
public async contactList () : Promise<string[]> { return {} as any }
public async contactQrcode (contactId: string) : Promise<string> { return { contactId } as any }

public async contactSelfName (newName: string) : Promise<boolean> { return true }
public async contactSelfSignature (signature: string) : Promise<boolean> { return true }
Copy link
Member

Choose a reason for hiding this comment

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

We should follow the current return type like we always used Promise<void> instead of others.

boolean does not make sense because if it fails, there must be an Error, and it should be thrown out instead of return a false.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will change this to Promise<void>

Copy link
Member

Choose a reason for hiding this comment

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

Ok, thanks.

BTW: does that mean you agree with me about this design: it should throw an exception instead of return false?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I agree with the design for updating actions: no return value, when fail, exception is expected.

@windmemory
Copy link
Member Author

Changes made to the function type, and please see my comments related to the naming issue.

@huan huan merged commit c31998f into wechaty:master Aug 6, 2018
@huan
Copy link
Member

huan commented Aug 6, 2018

After thinking more, I decided to use contactSelfXXX for all self-modification methods.

And there also introduced a breaking change, please see the code for details.

huan added a commit that referenced this pull request Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants