Show town square when selecting a team (#166)
Now selects the first channel if the default channel can’t be found
This commit is contained in:
parent
1566a79c93
commit
c94a0840fd
1 changed files with 7 additions and 6 deletions
|
|
@ -95,12 +95,13 @@ export function selectInitialChannel(teamId) {
|
|||
return async (dispatch, getState) => {
|
||||
const channels = getState().entities.channels.channels;
|
||||
|
||||
for (const channel of Object.values(channels)) {
|
||||
// TODO figure out how to handle when we can't find the town square
|
||||
if (channel.team_id === teamId && channel.name === Constants.DEFAULT_CHANNEL) {
|
||||
await selectChannel(channel.id)(dispatch, getState);
|
||||
break;
|
||||
}
|
||||
const channel = Object.values(channels).find((c) => c.team_id === teamId && c.name === Constants.DEFAULT_CHANNEL);
|
||||
if (channel) {
|
||||
await selectChannel(channel.id)(dispatch, getState);
|
||||
} else {
|
||||
// Handle case when the default channel cannot be found
|
||||
const firstChannel = Object.values(channels)[0];
|
||||
await selectChannel(firstChannel.id)(dispatch, getState);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue