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

Fixed typing status for typing from different device #802

Merged
merged 1 commit into from Mar 16, 2017

Conversation

smitbose
Copy link
Contributor

@smitbose smitbose commented Mar 4, 2017

This fixes the bug #628 .

While writing from another device, logged in with the same JID, the current code shows a different user is typing. This commit fixes that to show status message "Typing from another device" and "Stopped typing on the other device" in those cases.
It however leaves the previous behaviour unchanged in case of other users.
screenshot from 2017-03-05 02-12-16
screenshot from 2017-03-05 02-10-27

@smitbose
Copy link
Contributor Author

smitbose commented Mar 4, 2017

Also, @jcbrand, I was unsure of the particular the UI will be modified, so just kept the messages I felt would be suitable into the fix. Do review it and suggest improvements.

@jcbrand
Copy link
Member

jcbrand commented Mar 8, 2017

I didn't notice that you worked on the same ticket as @saganshul

I already merged his pull request. However, I like the change you made to show a different status message.

Can you please rebase your commits onto master, check whether the tests pass and then push again?

@smitbose
Copy link
Contributor Author

smitbose commented Mar 8, 2017

okay, sure @jcbrand

@smitbose
Copy link
Contributor Author

smitbose commented Mar 8, 2017

@jcbrand I've rebased the commits on master...

@jcbrand
Copy link
Member

jcbrand commented Mar 9, 2017

No, something went wrong.

If you look at the commits, there are now many more commits and two commits for Fixed typing status for typing from same device.

This is not how it's supposed to look after rebasing. Instead after rebasing there should just be your one commit to be merged into master.

@smitbose
Copy link
Contributor Author

smitbose commented Mar 9, 2017

Yes, I also think something went wrong somewhere. Basically, my typing-status branch was outdated, and upstream/master was ahead by several commits because I haven't worked on this branch after making the PR.

So, with my updated master, and while being in typing-status branch, I did git rebase master, followed by a git push -u origin typing-status.

Where did this go wrong?

@jcbrand
Copy link
Member

jcbrand commented Mar 9, 2017

The oldest commit in this PR is a merge you made. I think that's the problem. I suspect because of your merge your master was different and so you rebased onto a changed master.

There are a few ways to fix this. I think easiest to explain is to do:

git rebase -i HEAD~13

And then drop all the commits before your last one. Then rebase again and push.

Make sure to back up your work before you do this.

this.showStatusNotification(message.get('fullname')+' '+__('is typing'));
if(message.get('sender') === 'me') {
this.showStatusNotification('Typing from another device');
}
Copy link
Member

Choose a reason for hiding this comment

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

User-facing strings should be wrapped in __( ) so that they will get translated.

@@ -532,7 +542,7 @@
* See XEP-0085 Chat State Notifications.
*/
_converse.connection.send(
$msg({'to':this.model.get('jid'), 'type': 'chat'})
$msg({'to':this.model.get('jid'), 'type': 'chat', 'from': _converse.connection.jid})
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this 'from' attribute is necessary because it gets added automatically by strophe.js AFAICR. You can remove it. Unless you have a clear reason why it's needed.

@smitbose
Copy link
Contributor Author

@jcbrand This one is still lying unreviewed. If the changes are ok, I'll move on to writing tests and updating changelogs.

@jcbrand
Copy link
Member

jcbrand commented Mar 12, 2017

@smitbose yes please

@smitbose smitbose changed the title Fixed typing status for typing from same device Fixed typing status for typing from different device Mar 12, 2017
@smitbose
Copy link
Contributor Author

@jcbrand I was wondering what kind of test sould I write for this one. Basically, the way I'm testing this is openning up chatbox for the same receiver from two different resources and then trying to type something, and checking the typing status rendered. How can I simulate the same behaviour in a spec. Can you help me out here?

@jcbrand
Copy link
Member

jcbrand commented Mar 13, 2017

Open a chat box with a contact. Then receive a composing message for the currently logged in user (not from the contact), but from a different resource.

@jcbrand
Copy link
Member

jcbrand commented Mar 13, 2017

@smitbose You can copy/paste this test and modify it to send a composing carbon message instead of just a normal carbon message.

@smitbose
Copy link
Contributor Author

ok, right, thanks.

@smitbose
Copy link
Contributor Author

@jcbrand what to do about the changelog, because it says that saganshul worked on the same issue, i.e. #628 . Should I add another line referencing the same issue or should I override that line?

@jcbrand
Copy link
Member

jcbrand commented Mar 13, 2017

Add another line referencing the same issue.

@smitbose
Copy link
Contributor Author

@jcbrand PR updated with final modifications, specs and changelog edits. Please review.

docs/CHANGES.md Outdated
@@ -3,6 +3,7 @@
## 3.0.1 (Unreleased)

- #585 Duplicate contact created due to JID case sensivity [saganshul]
- #628 Fixes typing status for typing from different devices. [smitbose]
Copy link
Member

Choose a reason for hiding this comment

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

This is not descriptive of what was done. It's not a bugfix, you simply changed the message that gets displayed. Also please put it after saganshul's message.

@jcbrand
Copy link
Member

jcbrand commented Mar 15, 2017

@smitbose Almost done! A few small changes, then I'll merge.

@smitbose
Copy link
Contributor Author

@jcbrand I don't see any reviews asking for changes. I did the previous changes asked. Can you specify the small changes required?

spec/chatbox.js Outdated
it("can be a composing carbon message that this user sent from a different client, as defined in XEP-0280", mock.initConverse(function (_converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
Copy link
Member

Choose a reason for hiding this comment

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

Lines 1399 and 1400 are not needed AFAIK.

spec/chatbox.js Outdated
var chatbox = _converse.chatboxes.get(recipient_jid);
var chatboxview = _converse.chatboxviews.get(recipient_jid);
expect(chatbox).toBeDefined();
expect(chatboxview).toBeDefined();
Copy link
Member

Choose a reason for hiding this comment

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

The above two checks aren't necessary within this test.

spec/chatbox.js Outdated
@@ -1393,6 +1393,47 @@
var $events = chatboxview.$el.find('.chat-event');
expect($events.text()).toEqual(mock.cur_names[1] + ' is typing');
}));

it("can be a composing carbon message that this user sent from a different client, as defined in XEP-0280", mock.initConverse(function (_converse) {
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the , as defined in XEP-0280 part

spec/chatbox.js Outdated
@@ -1477,6 +1518,47 @@
var $events = chatboxview.$el.find('.chat-event');
expect($events.text()).toEqual(mock.cur_names[1] + ' has stopped typing');
}));

it("can be a paused carbon message that this user sent from a different client, as defined in XEP-0280", mock.initConverse(function (_converse) {
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the , as defined in XEP-0280 part

spec/chatbox.js Outdated
it("can be a paused carbon message that this user sent from a different client, as defined in XEP-0280", mock.initConverse(function (_converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
Copy link
Member

Choose a reason for hiding this comment

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

Lines 1524 and 1525 aren't needed AFAIK.

spec/chatbox.js Outdated
var chatbox = _converse.chatboxes.get(recipient_jid);
var chatboxview = _converse.chatboxviews.get(recipient_jid);
expect(chatbox).toBeDefined();
expect(chatboxview).toBeDefined();
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary checks in the context of this test.

@jcbrand
Copy link
Member

jcbrand commented Mar 16, 2017

Sorry, I forgot to submit my review.

@smitbose
Copy link
Contributor Author

@jcbrand made final changes. Please check...

@jcbrand jcbrand merged commit c976f3f into conversejs:master Mar 16, 2017
@jcbrand
Copy link
Member

jcbrand commented Mar 16, 2017

Looks good, thanks!

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