diff --git a/frontend/src/api.ts b/frontend/src/api.ts index ad22d7e..a05aa2e 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -45,7 +45,7 @@ export const API = { async createChannel(name: string) { const response = await API.request("POST", "channels", { name }); const json = await response.json(); - return json.channel as IChannel; + return json as IChannel; }, async deleteChannel(id: string) { diff --git a/frontend/src/views/main.ts b/frontend/src/views/main.ts index ada7b86..e05a3b4 100644 --- a/frontend/src/views/main.ts +++ b/frontend/src/views/main.ts @@ -162,7 +162,11 @@ export class MainView extends View { if (state.defaultChannelId) { this.switchChannel(state.defaultChannelId.toString()); } else { - this.switchChannel(state.channelList.channels[0].id.toString()); + if (state.channelList.channels.length > 0) { + this.switchChannel(state.channelList.channels[0].id.toString()); + } else { + this.createNewChannel(); + } } } state.save();