Merge pull request #758 from igniterealtime/spark-2313

Spark 2313 Fix History
This commit is contained in:
ilyaHlevnoy 2022-12-03 05:20:39 +03:00 committed by GitHub
commit 81eb885811
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 35 deletions

View File

@ -525,27 +525,35 @@ public class TranscriptWindow extends ChatArea implements ContextMenuListener
}
} );
}
ChatRoom room = null;
try{
room = SparkManager.getChatManager().getChatContainer().getActiveChatRoom();
}catch (Exception e){
Log.error( "An exception occurred while trying to get active chat room " + room, e );
}
// History window
if (!Default.getBoolean(Default.HISTORY_DISABLED) && Enterprise.containsFeature(Enterprise.HISTORY_TRANSCRIPTS_FEATURE)) {
popup.add( new AbstractAction( Res.getString( "action.viewlog" ) )
{
@Override
public void actionPerformed( ActionEvent e )
{
ChatRoom room = null;
try
{
room = SparkManager.getChatManager().getChatContainer().getActiveChatRoom();
HistoryWindow hw = new HistoryWindow( SparkManager.getUserDirectory(), room.getBareJid().toString() );
hw.showWindow();
}
catch ( Exception ex )
{
Log.error( "An exception occurred while trying to open history window for room " + room, ex );
}
}
} );
if(room != null && room.getChatType() == Message.Type.chat){
ChatRoom finalRoom = room;
popup.add(new AbstractAction( Res.getString( "action.viewlog" ) )
{
@Override
public void actionPerformed( ActionEvent e )
{
try
{
HistoryWindow hw = new HistoryWindow( SparkManager.getUserDirectory(), finalRoom.getJid().toString() );
hw.showWindow();
}
catch ( Exception ex )
{
Log.error( "An exception occurred while trying to open history window for room " + finalRoom, ex );
}
}
} );
}
}
}

View File

@ -1,5 +1,7 @@
package org.jivesoftware.spark.ui.history;
import org.jivesoftware.resource.Res;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
@ -44,17 +46,13 @@ public class HistoryWindow extends JFrame {
private static final String CONTENT_TYPE = "text/html";
private static final String EMPTY = "";
private static final String LABEL_SIZE = "Size:";
private static final String BTN_FIND = "Find";
private static final String BTN_CLOSE = "Close";
private static final Dimension SIZE = new Dimension(700, 400);
private static final Point LOCATION = new Point(400, 150);
private static final MessageFormat TITLE_FORMAT = new MessageFormat("{0}");
private static final MessageFormat LABEL_FORMAT = new MessageFormat("{0}");
private static final MessageFormat HISTORY_FILE_FORMAT = new MessageFormat(
"transcripts/{0}.xml");
private static final Font LABEL_FONT = new Font("Droid Sans", Font.BOLD, 16);
private static final Font SIZE_TEXT_FONT = new Font("Droid Sans",
private static final Font LABEL_FONT = new Font("Droid Sans",
Font.PLAIN, 14);
private static final Font TEXT_FONT = new Font("Droid Sans", Font.PLAIN, 13);
private static final Dimension SIZE_FIND_FIELD = new Dimension(100, 25);
@ -103,10 +101,10 @@ public class HistoryWindow extends JFrame {
historyFile = new XMLHistoryFile(historyStream);
sizeText = historyFile.getFormatSize();
btnClose = createJButton(BTN_CLOSE);
btnClose = createJButton(Res.getString("button.close"));
btnClose.setFont(TEXT_FONT);
btnFind = createJButton(BTN_FIND);
btnFind = createJButton(Res.getString("button.find"));
btnFind.setFont(TEXT_FONT);
HistoryTreeNode historyTreeTopNode = buildHistoryTree( historyFile, roomName );
@ -178,14 +176,9 @@ public class HistoryWindow extends JFrame {
private Component getSizePanel() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
JLabel label = createJLabel(LABEL_SIZE);
JLabel label = createJLabel(Res.getString("message.file.size",sizeText));
label.setFont(LABEL_FONT);
panel.add(label);
JLabel sizeTextLabel = createJLabel(EMPTY);
sizeTextLabel.setFont(SIZE_TEXT_FONT);
sizeTextLabel.setText(sizeText);
panel.add(sizeTextLabel);
return panel;
}

View File

@ -226,13 +226,13 @@ public class ChatTranscriptPlugin implements ChatRoomListener {
if (!pref.isChatHistoryEnabled()) {
return;
}
//If this it a MUC then don't persist this chat.
if(room.getChatType() == Message.Type.groupchat){
return;
}
EntityJid jid = room.getJid();
//If this it a MUC then don't persist this chat.
if(jid.hasNoResource() && !jid.getDomain().equals(domainServer)){
return;
}
//If this is a one-to-one chat( "user@domain.local" )
if(jid.hasResource() && jid.getDomain().equals(domainServer)){