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>;
|
private readonly event_registry: Registry<ConnectionEvents>;
|
||||||
channelTree: ChannelTree;
|
channelTree: ChannelTree;
|
||||||
|
|
||||||
|
connection_state: ConnectionState = ConnectionState.UNCONNECTED;
|
||||||
serverConnection: AbstractServerConnection;
|
serverConnection: AbstractServerConnection;
|
||||||
|
|
||||||
fileManager: FileManager;
|
fileManager: FileManager;
|
||||||
|
@ -349,6 +350,7 @@ export class ConnectionHandler {
|
||||||
@EventHandler<ConnectionEvents>("notify_connection_state_changed")
|
@EventHandler<ConnectionEvents>("notify_connection_state_changed")
|
||||||
private handleConnectionConnected(event: ConnectionEvents["notify_connection_state_changed"]) {
|
private handleConnectionConnected(event: ConnectionEvents["notify_connection_state_changed"]) {
|
||||||
if(event.new_state !== ConnectionState.CONNECTED) return;
|
if(event.new_state !== ConnectionState.CONNECTED) return;
|
||||||
|
this.connection_state = event.new_state;
|
||||||
|
|
||||||
log.info(LogCategory.CLIENT, tr("Client connected"));
|
log.info(LogCategory.CLIENT, tr("Client connected"));
|
||||||
this.log.log(server_log.Type.CONNECTION_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;
|
private handle_connection_state_change;
|
||||||
|
|
||||||
protected defaultState(): ServerEntryState {
|
protected defaultState(): ServerEntryState {
|
||||||
return { connection_state: "disconnected" };
|
return { connection_state: this.props.server ? ServerEntry.connectionState2String(this.props.server.channelTree.client.connection_state) : "disconnected" };
|
||||||
|
}
|
||||||
|
|
||||||
|
private static connectionState2String(state: ConnectionState) {
|
||||||
|
switch (state) {
|
||||||
|
case ConnectionState.AUTHENTICATING:
|
||||||
|
case ConnectionState.CONNECTING:
|
||||||
|
case ConnectionState.INITIALISING:
|
||||||
|
return "connecting";
|
||||||
|
|
||||||
|
case ConnectionState.CONNECTED:
|
||||||
|
return "connected";
|
||||||
|
|
||||||
|
case ConnectionState.DISCONNECTING:
|
||||||
|
case ConnectionState.UNCONNECTED:
|
||||||
|
return "disconnected";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected initialize() {
|
protected initialize() {
|
||||||
this.handle_connection_state_change = (event: ConnectionEvents["notify_connection_state_changed"]) => {
|
this.handle_connection_state_change = (event: ConnectionEvents["notify_connection_state_changed"]) => this.setState({
|
||||||
switch (event.new_state) {
|
connection_state: ServerEntry.connectionState2String(event.new_state)
|
||||||
case ConnectionState.AUTHENTICATING:
|
});
|
||||||
case ConnectionState.CONNECTING:
|
|
||||||
case ConnectionState.INITIALISING:
|
|
||||||
this.setState({ connection_state: "connecting" });
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ConnectionState.CONNECTED:
|
|
||||||
this.setState({ connection_state: "connected" });
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ConnectionState.DISCONNECTING:
|
|
||||||
case ConnectionState.UNCONNECTED:
|
|
||||||
this.setState({ connection_state: "disconnected" });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps: Readonly<ServerEntryProperties>, nextState: Readonly<ServerEntryState>, nextContext: any): boolean {
|
shouldComponentUpdate(nextProps: Readonly<ServerEntryProperties>, nextState: Readonly<ServerEntryState>, nextContext: any): boolean {
|
||||||
|
|
Loading…
Add table
Reference in a new issue