Refresh a channel's cached description when it changes
The description is fetched on demand and cached, but nothing invalidated it: notifychanneledited never carries the text, and the separate notifychanneldescriptionchanged was ignored. Handle that event, and refresh locally after our own edit, since the server does not notify the invoker. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -365,6 +365,7 @@ final class ConnectionEventHandler implements TS3Listener {
|
|||||||
if (has(e, "channel_name")) ch.name = e.get("channel_name");
|
if (has(e, "channel_name")) ch.name = e.get("channel_name");
|
||||||
if (has(e, "channel_order")) ch.order = e.getInt("channel_order");
|
if (has(e, "channel_order")) ch.order = e.getInt("channel_order");
|
||||||
if (has(e, "channel_icon_id")) ch.iconId = TeamspeakConnection.safeLong(e, "channel_icon_id");
|
if (has(e, "channel_icon_id")) ch.iconId = TeamspeakConnection.safeLong(e, "channel_icon_id");
|
||||||
|
if (has(e, "channel_topic")) ch.topic = e.get("channel_topic");
|
||||||
if (conn.isConnected()) {
|
if (conn.isConnected()) {
|
||||||
boolean current = conn.inOwnChannel(ch.id);
|
boolean current = conn.inOwnChannel(ch.id);
|
||||||
conn.sound(current
|
conn.sound(current
|
||||||
@@ -379,6 +380,19 @@ final class ConnectionEventHandler implements TS3Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Descriptions never travel with the notify, so a cached one has to be re-fetched.
|
||||||
|
* Only channels whose description was already loaded are refreshed; the rest pick the
|
||||||
|
* new text up the first time they are looked at.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onChannelDescriptionChanged(ChannelDescriptionEditedEvent e) {
|
||||||
|
ChannelNode ch = conn.getModel().getChannel(safeInt(e, "cid"));
|
||||||
|
if (ch == null || !ch.descriptionLoaded) return;
|
||||||
|
ch.descriptionLoaded = false;
|
||||||
|
conn.requestChannelInfo(ch.id);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChannelMoved(ChannelMovedEvent e) {
|
public void onChannelMoved(ChannelMovedEvent e) {
|
||||||
ChannelNode ch = conn.getModel().getChannel(safeInt(e, "cid"));
|
ChannelNode ch = conn.getModel().getChannel(safeInt(e, "cid"));
|
||||||
|
|||||||
@@ -919,6 +919,14 @@ public final class TeamspeakConnection implements TS3Listener {
|
|||||||
run("ts3j-channel-edit", (ignored, error) -> callback.accept(error), () -> {
|
run("ts3j-channel-edit", (ignored, error) -> callback.accept(error), () -> {
|
||||||
channels.edit(channelId, changes);
|
channels.edit(channelId, changes);
|
||||||
channels.writePermissions(channelId, setPermissions, removePermissions);
|
channels.writePermissions(channelId, setPermissions, removePermissions);
|
||||||
|
if (changes.containsKey("channel_description")) {
|
||||||
|
ChannelNode node = model.getChannel(channelId);
|
||||||
|
// the server does not notify the invoker of their own description change
|
||||||
|
if (node != null && node.descriptionLoaded) {
|
||||||
|
node.descriptionLoaded = false;
|
||||||
|
requestChannelInfo(channelId);
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user