function collapsedServers(state: List<ServerId> = List<ServerId>(), action: Action): List<ServerId> { switch (action.type) { case ActionType.TOGGLE_SERVER_COLLAPSE: let serverId = action.payload.serverId if (state.includes(serverId)) { return state.filterNot(it => it == serverId) as List<ServerId> } else { return state.push(serverId) } default: return state } }