Don't handle offline messages if the corresponding chat room has already been created.
This eliminates duplicate messages in the transcript window when the user reconnects while the chat room is open.
@@ -402,16 +402,21 @@ public class Workspace extends JPanel implements StanzaListener {
if (bareJID == null) {
return;
}
+
+ // Create the room if it does not exist.;
+ try {
+ ChatManager.getInstance().getChatContainer().getChatRoom(bareJID);
+ } catch (ChatRoomNotFoundException e) {
+ String nickname;
ContactItem contact = contactList.getContactItemByJID(bareJID);
- String nickname = bareJID.getLocalpartOrNull() == null ? null : bareJID.getLocalpartOrNull().toString();
if (contact != null) {
nickname = contact.getDisplayName();
+ } else {
+ nickname = bareJID.getLocalpartOrNull() == null ? null : bareJID.getLocalpartOrNull().toString();
}
- // Create the room if it does not exist.
ChatRoom room = SparkManager.getChatManager().createChatRoom(bareJID, nickname, nickname);
- if(!SparkManager.getChatManager().getChatContainer().getChatFrame().isVisible())
- {
+ if (!SparkManager.getChatManager().getChatContainer().getChatFrame().isVisible()) {
SparkManager.getChatManager().getChatContainer().getChatFrame().setVisible(true);
}
@@ -423,6 +428,7 @@ public class Workspace extends JPanel implements StanzaListener {
SparkManager.getMessageEventManager().sendDeliveredNotification(message.getFrom(), message.getStanzaId());
SparkManager.getMessageEventManager().sendDisplayedNotification(message.getFrom(), message.getStanzaId());
}
+ }
/**
* Creates a new room based on an anonymous user.
