-
-
Notifications
You must be signed in to change notification settings - Fork 763
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
implement /destroy command in muc #1388
Conversation
67f1ff6
to
5f8f315
Compare
8ca2731
to
f16b6d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ChaosKid42!
I have a few small improvement suggestions.
src/converse-muc-views.js
Outdated
} | ||
this.destroy( | ||
this.model.get('jid'), args[0], | ||
this.onDestroySuccess.bind(this), this.onCommandError.bind(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making a new method onDestroySuccess
, you can simply use this.close
here, and you can use an arrow function to avoid having to use .bind
.
In destroy
, you can simply return _converse.api.sendIQ(iq)
so that it returns a promise.
So it could be something like this:
this.destroy(this.model.get('jid'), args[0])
.then(() => this.close())
.catch(e => this.onCommandError(e));
src/converse-muc-views.js
Outdated
const destroy = $build("destroy"); | ||
const iq = $iq({to: groupchat, type: "set"}).c("query", {xmlns: Strophe.NS.MUC_OWNER}).cnode(destroy.node); | ||
if (reason && reason.length > 0) { iq.c("reason", reason); } | ||
return _converse.api.sendIQ(iq).then(onSuccess).catch(onError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like us to move away from using callbacks in favour of using promises.
Here, you can simply return return _converse.api.sendIQ(iq)
and then later when you call destroy
you can either use then
and catch
or async/await
.
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) { | ||
sent_IQ = iq; | ||
IQ_id = sendIQ.bind(this)(iq, callback, errback); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a dealbreaker for merging, but I'd like us to move away from using var
in favour of let
and const
.
564e03d
to
5ec837c
Compare
5ec837c
to
2315ef1
Compare
@jcbrand Thanks fo your review. Updated the PR. |
This implements the possibility to destroy a MUC.