Trying to implement highlighting of new messages

Asked by Vassil Dichev

Hello,

I am trying to implement a functionality similar to the Pidgin Markerline plugin in SamePlace. In Pidgin, there's a line which moves below all messages every time the chat pane loses focus. This way when you come back to the chat pane, you can see clearly which messages have arrived since you last had them in sight.

In order to implement this, there must be a way to indicate you're no longer watching this message pane. In SamePlace, I'm striving to achieve that when:

a) the message loses focus, e.g. a chat with another user is selected
b) the message is closed
c) the contact pane is hidden or compact

So far a) has been really easy- I added one line appending a horizontal separator in the window blur event handler of the chat area. This works when a different message pane is selected.

The tough nut to crack is b). In this case, the expected behavior would be the same if the line is added when the chat pane is closed or opened, because the first new message would open the pane. This would mean there are no messages between closing and reopening the message tab. But I can't seem to find a way to append a line *after* all messages, because they are added after the init function completes.

c) is optional.

How could I proceed with b)? Should I try to mess with the xmpp-incoming queue? Doesn't seem viable to me as well, since it's also empty at the time init finishes, if my observations are correct.

Thanks,
Vassil

Question information

Language:
English Edit question
Status:
Answered
For:
SamePlace Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Massimiliano Mirra (bard-hyperstruct) said :
#1

Vassil,

if I understand correctly, the problem with b) is that you want, when
conversation first opens as a result of a message coming in, to show a
line after the last message -- however you can't do that in init()
because messages are injected in conversation *after* conversation is
initialized. Did I get it right?

You could track the focus status of a conversation in a variable.
Every time a message comes in, check the variable; if true, draw line
after last message, otherwise do nothing.

(Additionally, if you're manipulating the DOM to display a line, you
might want to set a CSS class on the last message element instead, and
associate "border-bottom: 1px solid gray;" or similar to that class.)

By the way, this sounds like a useful feature to have.

Revision history for this message
Vassil Dichev (vdichev) said :
#2

Hello bard,

Yes, with the following addition- I want the line displayed every time a conversation opens (not only the first time) as a result not only of an incoming message but possibly of the user opening a conversation. A much more appropriate comparison is not with Pidgin, but with Meebo- whenever a conversation is reopened (either due to a new message or user-initiated), the old messages are greyed out- in effect, the same logic is applied.

Checking the variable is OK, but my problem is to detect the status change. Besides, focus doesn't change between initialization and the existing messages being populated, am I correct? Then I would need to detect status change when the conversation is closed (which should produce an identical result). But, as far as I understand it, when the conversation is closed, all state related to chat.xhtml is lost. I would then need to access a variable outside the scope of chat.xhtml, right?

Regards,
Vassil

Revision history for this message
Massimiliano Mirra (bard-hyperstruct) said :
#3

> a conversation is reopened (either due to a new message or user-
> initiated), the old messages are greyed out- in effect, the same logic
> is applied.

Would it help if a jabber:x:delay were injected into messages before
they are saved into the circular backlog? The chat application could
use that to determine the color.

> Checking the variable is OK, but my problem is to detect the status
> change. Besides, focus doesn't change between initialization and the
> existing messages being populated, am I correct?

Yes, correct.

> Then I would need to
> detect status change when the conversation is closed (which should
> produce an identical result). But, as far as I understand it, when the
> conversation is closed, all state related to chat.xhtml is lost. I would
> then need to access a variable outside the scope of chat.xhtml, right?

Yes, and that wouldn't do.

See if the jabber:x:delay idea fits the bill, otherwise we'll try
coming up with something else.

Revision history for this message
Vassil Dichev (vdichev) said :
#4

(one hard-disk crash later) Sorry for my delay in answering, but this was some great insight, thanks!

Your reply has been really helpful, I finally found the time and solved b) as well! Now the only thing I want to ask before marking my problem as solved is: where do I ask for details on submitting a patch? :) in the chatroom? in Twitter?

Revision history for this message
Launchpad Janitor (janitor) said :
#5

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Massimiliano Mirra (bard-hyperstruct) said :
#6

http://sameplace.cc/wiki/development#sending-patches (freshly baked. :-))

If something is unclear, ping me at xmpp:bard [at] sameplace [dot] cc.

Can you help with this problem?

Provide an answer of your own, or ask Vassil Dichev for more information if necessary.

To post a message you must log in.