lbry-desktop/ui/component/subscribeMarkAsRead/view.jsx

35 lines
932 B
React
Raw Normal View History

// @flow
import * as ICONS from 'constants/icons';
import React, { PureComponent } from 'react';
import Button from 'component/button';
type Props = {
channel: ?string,
doRemoveUnreadSubscriptions: (?string) => void,
};
export default class MarkAsRead extends PureComponent<Props> {
constructor() {
super();
(this: any).handleClick = this.handleClick.bind(this);
}
handleClick() {
const { channel, doRemoveUnreadSubscriptions } = this.props;
// If there is no channel, mark all as read
// If there is a channel, only mark that channel as read
if (channel) {
doRemoveUnreadSubscriptions(channel);
} else {
doRemoveUnreadSubscriptions();
}
}
render() {
2018-11-28 00:08:29 +01:00
const { channel } = this.props;
const label = channel ? __('Mark as read') : __('Mark all as read');
2019-05-07 23:38:29 +02:00
return <Button button="inverse" icon={ICONS.COMPLETE} label={label} onClick={this.handleClick} />;
}
}