fix(labels): Do not re-use mail labels if they're removable

This commit is contained in:
Ben Gotow 2016-03-10 17:08:38 -08:00
parent d28c79fc75
commit 7c2fd2a91b
3 changed files with 14 additions and 17 deletions

View file

@ -227,7 +227,7 @@ class MessageList extends React.Component
<MailImportantIcon thread={@state.currentThread}/>
<div style={flex: 1}>
<span className="message-subject">{subject}</span>
<MailLabelSet thread={@state.currentThread} includeCurrentCategories={true} />
<MailLabelSet removable={true} thread={@state.currentThread} includeCurrentCategories={true} />
</div>
{@_renderIcons()}
</div>

View file

@ -48,17 +48,6 @@
-webkit-font-smoothing: subpixel-antialiased;
}
// Do not show the "removable" X on mail labels within the thread list.
.mail-label {
padding: 1px 8px;
.inner {
position: inherit;
}
.x {
display: none;
}
}
.swipe-backing {
background-color: darken(@background-primary, 10%);
&::after {

View file

@ -16,6 +16,7 @@ export default class MailLabelSet extends React.Component {
static propTypes = {
thread: React.PropTypes.object.isRequired,
includeCurrentCategories: React.PropTypes.bool,
removable: React.PropTypes.bool,
};
_onRemoveLabel(label) {
@ -45,15 +46,22 @@ export default class MailLabelSet extends React.Component {
if (ignoredNames.includes(label.name) || ignoredIds.includes(label.id)) {
continue;
}
if (LabelComponentCache[label.id] === undefined) {
LabelComponentCache[label.id] = (
if (this.props.removable) {
labels.push (
<MailLabel
label={label}
key={label.id}
onRemove={()=> this._onRemoveLabel(label)}/>
);
onRemove={()=> this._onRemoveLabel(label)} />
)
} else {
if (LabelComponentCache[label.id] === undefined) {
LabelComponentCache[label.id] = (
<MailLabel label={label} key={label.id} />
);
}
labels.push(LabelComponentCache[label.id]);
}
labels.push(LabelComponentCache[label.id]);
}
}
return (