|  | @@ -93,9 +93,7 @@ Boards.helpers({
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    getLabel(name, color) {
 | 
	
		
			
				|  |  | -    return this.labels.find((current) => {
 | 
	
		
			
				|  |  | -      return ((current.name === name) && (current.color === color));
 | 
	
		
			
				|  |  | -    });
 | 
	
		
			
				|  |  | +    return _.findWhere(this.labels, { name, color });
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    labelIndex(labelId) {
 | 
	
	
		
			
				|  | @@ -138,11 +136,22 @@ Boards.mutations({
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    addLabel(name, color) {
 | 
	
		
			
				|  |  |      const _id = Random.id(6);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // If an empty label of a given color already exists we don't want to create
 | 
	
		
			
				|  |  | +    // an other one because they would be indistinguishable in the UI (they
 | 
	
		
			
				|  |  | +    // would still have different `_id` but that is not exposed to the user).
 | 
	
		
			
				|  |  | +    if (name === '' && this.getLabel(name, color)) {
 | 
	
		
			
				|  |  | +      return {};
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      return { $push: {labels: { _id, name, color }}};
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    editLabel(labelId, name, color) {
 | 
	
		
			
				|  |  |      const labelIndex = this.labelIndex(labelId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    if (name === '' && this.getLabel(name, color)) {
 | 
	
		
			
				|  |  | +      return {};
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      return {
 | 
	
		
			
				|  |  |        $set: {
 | 
	
		
			
				|  |  |          [`labels.${labelIndex}.name`]: name,
 | 
	
	
		
			
				|  | @@ -299,8 +308,8 @@ if (Meteor.isServer) {
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  // If the user removes a label from a board, we have to remove references to
 | 
	
		
			
				|  |  | -  // this label in all cards of the board.
 | 
	
		
			
				|  |  | +  // If the user remove one label from a board, we cant to remove reference of
 | 
	
		
			
				|  |  | +  // this label in any card of this board.
 | 
	
		
			
				|  |  |    Boards.after.update((userId, doc, fieldNames, modifier) => {
 | 
	
		
			
				|  |  |      if (!_.contains(fieldNames, 'labels') ||
 | 
	
		
			
				|  |  |        !modifier.$pull ||
 |