Fixed the "Not connected" channel tree server entry bug
This commit is contained in:
parent
9dfa948105
commit
cf7bd3b3c6
2 changed files with 22 additions and 19 deletions
|
@ -123,6 +123,7 @@ export class ConnectionHandler {
|
|||
private readonly event_registry: Registry<ConnectionEvents>;
|
||||
channelTree: ChannelTree;
|
||||
|
||||
connection_state: ConnectionState = ConnectionState.UNCONNECTED;
|
||||
serverConnection: AbstractServerConnection;
|
||||
|
||||
fileManager: FileManager;
|
||||
|
@ -349,6 +350,7 @@ export class ConnectionHandler {
|
|||
@EventHandler<ConnectionEvents>("notify_connection_state_changed")
|
||||
private handleConnectionConnected(event: ConnectionEvents["notify_connection_state_changed"]) {
|
||||
if(event.new_state !== ConnectionState.CONNECTED) return;
|
||||
this.connection_state = event.new_state;
|
||||
|
||||
log.info(LogCategory.CLIENT, tr("Client connected"));
|
||||
this.log.log(server_log.Type.CONNECTION_CONNECTED, {
|
||||
|
|
|
@ -30,28 +30,29 @@ export class ServerEntry extends TreeEntry<ServerEntryProperties, ServerEntrySta
|
|||
private handle_connection_state_change;
|
||||
|
||||
protected defaultState(): ServerEntryState {
|
||||
return { connection_state: "disconnected" };
|
||||
return { connection_state: this.props.server ? ServerEntry.connectionState2String(this.props.server.channelTree.client.connection_state) : "disconnected" };
|
||||
}
|
||||
|
||||
protected initialize() {
|
||||
this.handle_connection_state_change = (event: ConnectionEvents["notify_connection_state_changed"]) => {
|
||||
switch (event.new_state) {
|
||||
private static connectionState2String(state: ConnectionState) {
|
||||
switch (state) {
|
||||
case ConnectionState.AUTHENTICATING:
|
||||
case ConnectionState.CONNECTING:
|
||||
case ConnectionState.INITIALISING:
|
||||
this.setState({ connection_state: "connecting" });
|
||||
break;
|
||||
return "connecting";
|
||||
|
||||
case ConnectionState.CONNECTED:
|
||||
this.setState({ connection_state: "connected" });
|
||||
break;
|
||||
return "connected";
|
||||
|
||||
case ConnectionState.DISCONNECTING:
|
||||
case ConnectionState.UNCONNECTED:
|
||||
this.setState({ connection_state: "disconnected" });
|
||||
break;
|
||||
return "disconnected";
|
||||
}
|
||||
}
|
||||
|
||||
protected initialize() {
|
||||
this.handle_connection_state_change = (event: ConnectionEvents["notify_connection_state_changed"]) => this.setState({
|
||||
connection_state: ServerEntry.connectionState2String(event.new_state)
|
||||
});
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps: Readonly<ServerEntryProperties>, nextState: Readonly<ServerEntryState>, nextContext: any): boolean {
|
||||
|
|
Loading…
Add table
Reference in a new issue