Skip to content
This repository was archived by the owner on Mar 7, 2018. It is now read-only.

Infer from url when no team name is provided #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/browser/app-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ var onSetConnectionState = function(currentState, connectionState){
};

var onAddTeam = function(currentState, team){
if (!team.name) {
team.name = team.url.replace(/[^:]*:\/\/[^\/]*\/([^/]*)(\/.*|$)/, '$1')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the correct place for this if it intends to solve #73. This file manages state, which is initialized from the loaded configuration. By the time we get to this file, we need to have already handled the missing team.name

This check should be inside the src/load-settings.js as a 'validateState()` function, but a simple near-term solution would be to put the check within the component itself.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should be inside the src/load-settings.js.

This is where I started at first but I found it suboptimal to synthesise name here, plus I was in need to push out a new backwards-compatible build to my users ASAP.

}
team.unreadCount = 0;
team.mentionCount = 0;
team.themeData = defaultThemeData;
Expand Down
2 changes: 1 addition & 1 deletion src/browser/team-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var React = require("react");
var TeamButton = React.createClass({
render: function(){
var team = this.props.team;
var iconText = team.name.substr(0,1);
var iconText = team.name.substr(0,1).toUpperCase();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good thought

var isSelected = (team.name === this.props.selectedTeam);
var selectedClass = isSelected ? "selected" : "not-selected";
var unreadCount = this.processCount(team.unreadCount);
Expand Down