Fix HistoryWindow for MUC

This commit is contained in:
Sergey Ponomarev
2026-07-21 12:10:48 +03:00
parent 28113aa843
commit 0393662fcb
2 changed files with 17 additions and 26 deletions

View File

@ -1,6 +1,8 @@
package org.jivesoftware.spark.ui.history;
import org.jivesoftware.resource.Res;
import org.jivesoftware.sparkimpl.plugin.transcripts.ChatTranscripts;
import org.jxmpp.jid.EntityJid;
import java.awt.Color;
import java.awt.Component;
@ -12,7 +14,6 @@ import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
@ -44,8 +45,6 @@ public class HistoryWindow extends JFrame {
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.PLAIN, 14);
private static final Font TEXT_FONT = new Font("Droid Sans", Font.PLAIN, 13);
@ -64,7 +63,7 @@ public class HistoryWindow extends JFrame {
private XMLHistoryFile historyFile;
private TreeModel historyOriginalModel;
public HistoryWindow(InputStream is, String roomName) {
private HistoryWindow(InputStream is, String roomName) {
setPreferredSize(SIZE);
setLocation(LOCATION);
setResizable(true);
@ -74,11 +73,9 @@ public class HistoryWindow extends JFrame {
initComponents();
}
public HistoryWindow(File file, String roomName)
public HistoryWindow(EntityJid roomName)
throws FileNotFoundException {
this(new FileInputStream(new File(file,
HISTORY_FILE_FORMAT.format(new String[] { roomName }))),
roomName);
this(new FileInputStream(ChatTranscripts.getTranscriptFile(roomName)), roomName.asUnescapedString());
}
public void showWindow() {

View File

@ -36,6 +36,7 @@ import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.plugin.manager.Enterprise;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import org.jxmpp.jid.EntityJid;
import org.jxmpp.jid.parts.Resourcepart;
import javax.swing.*;
@ -532,27 +533,20 @@ public class TranscriptWindow extends ChatArea implements ContextMenuListener
// History window
if (!Default.getBoolean(Default.HISTORY_DISABLED) && Enterprise.containsFeature(Enterprise.HISTORY_TRANSCRIPTS_FEATURE)) {
if(room != null && room.getChatType() == Message.Type.chat){
ChatRoom finalRoom = room;
popup.add(new AbstractAction( Res.getString( "action.viewlog" ) )
{
EntityJid roomJid = room.getJid();
popup.add(new AbstractAction(Res.getString("action.viewlog")) {
@Override
public void actionPerformed( ActionEvent e )
{
try
{
HistoryWindow hw = new HistoryWindow( SparkManager.getUserDirectory(), finalRoom.getJid().toString() );
public void actionPerformed(ActionEvent e) {
try {
HistoryWindow hw = new HistoryWindow(roomJid);
hw.showWindow();
}
catch ( Exception ex )
{
Log.error( "An exception occurred while trying to open history window for room " + finalRoom, ex );
} catch (Exception ex) {
Log.error("An exception occurred while trying to open history window for room " + roomJid, ex);
}
}
});
}
}
}
@Override
public boolean handleDefaultAction( MouseEvent e )