Skip to content

Commit

Permalink
fix: Automatic server selection - text while waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
juanky201271 committed Jan 28, 2024
1 parent ae54919 commit 8d1b47a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/components/loadingscreen/LoadingScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ class LoadingScreen extends Component<LoadingScreenProps & RouteComponentProps,
constructor(props: LoadingScreenProps & RouteComponentProps) {
super(props);

let currentStatus: string = "Loading...",
let currentStatus: string | JSX.Element = (
<span>
Checking servers to connect...
<br />
This process can take several seconds/minutes depends of the Server's status.
</span>
),
currentStatusIsError: boolean = false,
changeAnotherWallet: boolean = false,
serverUris: Server[] = [];
Expand Down Expand Up @@ -166,10 +172,7 @@ class LoadingScreen extends Component<LoadingScreenProps & RouteComponentProps,
});
};

loadServer = async () => {
// checking servers
const prevCurrentStatus = this.state.currentStatus;

loadServer = async () => {
// Try to read the default server
const settings = await ipcRenderer.invoke("loadSettings");
console.log('SETTINGS;;;;;;;;;', settings);
Expand Down Expand Up @@ -227,22 +230,20 @@ class LoadingScreen extends Component<LoadingScreenProps & RouteComponentProps,
}
}

// if empty is the first time and if auto => App needs to check the srvers.
// if empty is the first time and if auto => App needs to check the servers.
let servers: Server[] = this.state.serverUris;

if (selection === 'auto' && servers.length === 0) {
this.setState({ currentStatus: "Checking " + serverUrisList().length + " servers to connect..." });
servers = this.calculateServerLatency(serverUrisList()).filter(s => s.latency !== null).sort((a, b) => (a.latency ? a.latency : Infinity) - (b.latency ? b.latency : Infinity));
server = servers[0].uri;
chain_name = servers[0].chain_name;
await ipcRenderer.invoke("saveSettings", { key: "serveruri", value: server });
await ipcRenderer.invoke("saveSettings", { key: "serverchain_name", value: chain_name });
}

console.log('&&&&&&&&----------', server, chain_name, selection);
console.log('&&&&&&&&---------', server, chain_name, selection);

this.setState({
currentStatus: prevCurrentStatus,
serverUris: servers,
url: server,
chain: chain_name,
Expand Down

0 comments on commit 8d1b47a

Please sign in to comment.