forum: use 'extract' in GroupBadge instead of 'delete'

This commit is contained in:
David Sevilla Martin 2020-03-18 16:51:56 -04:00
parent babbda044b
commit 3027916d97
No known key found for this signature in database
GPG Key ID: F764F1417E16B15F
2 changed files with 9 additions and 9 deletions

View File

@ -1,16 +1,17 @@
import Badge from './Badge';
import extract from '../utils/extract';
export default class GroupBadge extends Badge {
static initProps(props) {
super.initProps(props);
if (props.group) {
props.icon = props.group.icon();
props.style = { backgroundColor: props.group.color() };
props.label = typeof props.label === 'undefined' ? props.group.nameSingular() : props.label;
props.type = `group--${props.group.id()}`;
const group = extract(props, 'group');
delete props.group;
if (group) {
props.icon = group.icon();
props.style = { backgroundColor: group.color() };
props.label = typeof props.label === 'undefined' ? group.nameSingular() : props.label;
props.type = `group--${group.id()}`;
}
}
}

View File

@ -4,13 +4,12 @@ import avatar from '../../common/helpers/avatar';
import username from '../../common/helpers/username';
import userOnline from '../../common/helpers/userOnline';
import listItems from '../../common/helpers/listItems';
import { PostProps } from './Post';
import LinkButton from '../../common/components/LinkButton';
import { PostProp } from '../../common/concerns/ComponentProps';
/**
* The `PostUser` component shows the avatar and username of a post's author.
*/
export default class PostUser extends Component<PostProps> {
export default class PostUser extends Component<PostProp> {
/**
* Whether or not the user hover card is visible.
*/