How do you set it to not show old messages? Right now the lowest you can go is 10. It would be great if the option was 0.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Category: support » feature

yes, this seems reasonable.

jct’s picture

This may be a bit of a hack (I'm no programmer), but i was able to achieve this end by changing the $i = 1 to $i = 0 for both the chat room and chat (lines 113 and 362).

Before

 $old_msg_range = array();
  for ($i = 1; $i <= 20; $i++) {
    $old_msg_range[$i] = $i * 10;
  }

After

  $old_msg_range = array();
  for ($i = 0; $i <= 20; $i++) {
    $old_msg_range[$i] = $i * 10;
  }
jct’s picture

Status: Active » Needs review
FileSize
862 bytes

Sorry for the double post. Decided after the fact to try to create a patch (my first try). If something's not right, please let me know. I'm eager to learn.

truyenle’s picture

FileSize
46.72 KB

@ jct, the patch does work with FF, Safari, and Chrom but not with IE.

When setting the Old message to 0 => 'offset().top' is null or not an object. see images

Truyenle

glitz’s picture

unfortunatly this is not working for me. was there anything else changed in chatroom.module. Im primairly focusing on changing this feature for chats only( as i do not use chatrooms)

thanks! :)

jct’s picture

@truyenle I tested it a bit in IE and didn't get that error. Can you provide a bit more information like your IE version and what caused the error (saving a new chat, using a chat, etc.)? Thanks.

@glitz The patch should have changed the setting for both chats and chatrooms. It's my first attempt at a patch, so perhaps I didn't do something correctly.

As I was testing things more, I realized that a more elegant solution would be to have 0 old chats show up that are older than a few minutes. That's beyond my programming abilities, unfortunately.

glitz’s picture

"As I was testing things more, I realized that a more elegant solution would be to have 0 old chats show up that are older than a few minutes. That's beyond my programming abilities, unfortunately."

this feature would actually be perfect...

glitz’s picture

I attempted to apply the patch and it did not take for me for some reason. Is there maybe a line hack in the chatroom.form file that I could edit?

jct’s picture

Take a look at the code change in http://drupal.org/node/864600#comment-3486554 and be sure to do it for both lines 113 and 362.

glitz’s picture

hmm. didnt work for me. this is how i saved it:

line 113:
$old_msg_range = array();
for ($i = 0; $i <= 20; $i++) {
$old_msg_range[$i] = $i * 10;

line 362:
$previous_msg_range = array();
for ($i = 0; $i <= 20; $i++) {
$previous_msg_range[$i] = $i * 10;

I will try my hand at the patch again. I am new to applying patches so it may be my fault...

Thanks,
Chris

truyenle’s picture

@jct: Sorry, for the late reply. I test it both in IE7 and IE8.
When setting the Old message to 0 => "'offset().top' is null or not an object" message is shown up when you visit the chat node and do chatting.

Thanks

truyenle’s picture

Any update on this jct? I means the patch doesn't work in IE.

Thanks.

truyenle’s picture

jct or anyone? please. Thanks

jct’s picture

After a bit of Googling, my hunch is there's a problem in how IE is interpreting the Javascript (here is a lead). It might be possible to make some changes to the JS code, but that's beyond my means. I did some testing in IE 8 and wasn't able to replicate the problem. Is anyone else seeing it? Sorry I'm unable to help more.

davidag’s picture

I've been doing some research on how to fix the IE error you mentioned. After some testing I've been able to avoid the error and keep the rest of the functionalities working (I think).

Please, be aware that I have no experience programming with jQuery nor using the Drupal 6 API. This was just a quick fix.

Just change line 12 of chatroom.js as follows:

if (Drupal.settings.chatroom.latestMsgId > 0 && $('div.new-message').val() != undefined) {

I hope it works for you :-)

PD: Btw, you have to apply the patch on message 3 in order to select 0 old messages...

truyenle’s picture

FileSize
815 bytes

Thank davidag, that pretty much cool!.

Actually, StuartEngelhardt just also help me to create this patch for a fix.

Thanks

jct’s picture

Version: 6.x-2.12 » 6.x-2.x-dev

Here's a patch against 6.x-2.x-dev (April 10) that combines both of the above patches. Since I didn't experience the issue in IE, could someone test?

jct’s picture

FileSize
1.45 KB

This time with the attachment :P