Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
Add some missing typing around a couple ServerEntry, ensuring we alwa…
Browse files Browse the repository at this point in the history
…ys set all the required fields
  • Loading branch information
bilou84 committed Feb 19, 2018
1 parent 9c8cfee commit 9cb551b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/renderer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function load(callback: (err: Error) => void) {

if (dataJSON == null) {
// Setup defaults
const myServerEntry = { hostname: "127.0.0.1", port: "4237", label: i18n.t("server:myServer"), id: "0" };
const myServerEntry: ServerEntry = { id: "0", hostname: "127.0.0.1", port: "4237", label: i18n.t("server:myServer") };
favoriteServers = [ myServerEntry ];
favoriteServersById[myServerEntry.id] = myServerEntry;

Expand Down
3 changes: 2 additions & 1 deletion src/renderer/sidebar/AddOrEditServerDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ export default class AddOrEditServerDialog extends BaseDialog<AddOrEditServerRes
}

submit() {
const result = {
const result: ServerEntry = {
id: null,
hostname: this.hostnameInputElt.value,
port: this.portInputElt.value !== "" ? this.portInputElt.value : null,
label: this.labelInputElt.value
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/tabs/openServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function makeServerTab(serverEntry: ServerEntry) {

const locationElt = document.createElement("div");
locationElt.className = "location";
locationElt.textContent = `${serverEntry.hostname}:${serverEntry.port}`;
locationElt.textContent = serverEntry.hostname + (serverEntry.port != null ? `:${serverEntry.port}` : "");
labelElt.appendChild(locationElt);

const nameElt = document.createElement("div");
Expand Down

0 comments on commit 9cb551b

Please sign in to comment.