chat history: rebuild pmbox when all is cleared

Additionally it is unnecessary to manually remove messages when the clear option is vanilla, since it will do it already
This commit is contained in:
Adam
2021-05-23 11:10:54 -04:00
parent 945f0b6d77
commit b5375ae487
2 changed files with 16 additions and 3 deletions

View File

@@ -47,6 +47,12 @@ public final class ScriptID
@ScriptArguments(integer = 1, string = 1)
public static final int CHATBOX_INPUT = 96;
/**
* Rebuilds the chatbox and the pmbox
*/
@ScriptArguments()
public static final int SPLITPM_CHANGED = 83;
/**
* Rebuilds the chatbox
*/

View File

@@ -317,6 +317,14 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
log.debug("Clearing chatbox history for tab {}", tab);
clearMessageQueue(tab);
if (tab.getAfter() == null)
{
// if the tab has a vanilla Clear option, it isn't necessary to delete the messages ourselves.
return;
}
boolean removed = false;
for (ChatMessageType msgType : tab.getMessageTypes())
{
@@ -339,10 +347,9 @@ public class ChatHistoryPlugin extends Plugin implements KeyListener
if (removed)
{
clientThread.invoke(() -> client.runScript(ScriptID.BUILD_CHATBOX));
// this rebuilds both the chatbox and the pmbox
clientThread.invoke(() -> client.runScript(ScriptID.SPLITPM_CHANGED));
}
clearMessageQueue(tab);
}
@Override