diff options
author | Damian Minkov <damencho@jitsi.org> | 2013-09-12 11:36:21 +0300 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2013-09-12 11:36:21 +0300 |
commit | 2c159b4d058ba978ebbaf9ce6b05ace1df846668 (patch) | |
tree | df69383a2376c8ede0a5390ef1edb1bf4894e944 /src | |
parent | 0f132ff1b08548dc30068a4d37f19a75685cc02c (diff) | |
download | jitsi-2c159b4d058ba978ebbaf9ce6b05ace1df846668.zip jitsi-2c159b4d058ba978ebbaf9ce6b05ace1df846668.tar.gz jitsi-2c159b4d058ba978ebbaf9ce6b05ace1df846668.tar.bz2 |
Saves last seen message coming from server as chat room history and skip older history messages from now on.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java index dc9ebb2..9c9cc31 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java @@ -1701,6 +1701,18 @@ public class ChatRoomJabberImpl implements PacketListener { /** + * The timestamp of the last history message sent to the UI. + * Do not send earlier or messages with the same timestamp. + */ + private Date lastSeenDelayedMessage = null; + + /** + * The property to store the timestamp. + */ + private static final String LAST_SEEN_DELAYED_MESSAGE_PROP + = "lastSeenDelayedMessage"; + + /** * Process a packet. * @param packet to process. */ @@ -1720,6 +1732,41 @@ public class ChatRoomJabberImpl if(delay != null) { timeStamp = delay.getStamp(); + + // This is a delayed chat room message, a history message for + // the room coming from server. Lets check have we already + // shown this message and if this is the case skip it + // otherwise save it as last seen delayed message + if(lastSeenDelayedMessage == null) + { + // initialise this from configuration + String timestamp = + ConfigurationUtils.getChatRoomProperty( + provider, + getIdentifier(), + LAST_SEEN_DELAYED_MESSAGE_PROP); + + try + { + lastSeenDelayedMessage = + new Date(Long.parseLong(timestamp)); + } + catch(Throwable t) + {} + } + + if(lastSeenDelayedMessage != null + && !timeStamp.after(lastSeenDelayedMessage)) + return; + + // save it in configuration + ConfigurationUtils.updateChatRoomProperty( + provider, + getIdentifier(), + LAST_SEEN_DELAYED_MESSAGE_PROP, + String.valueOf(timeStamp.getTime())); + + lastSeenDelayedMessage = timeStamp; } else { |