mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +08:00
251d7c44d1
* Initial commit * SVG-based graph components * Add histogram, pull data into graphs * Loading animation, timespan descriptions * Improvements to read receipt / link tracking section * Initial pass at subject line analysis * Fixes to subject-line stats * Fix theme `ui-variables` include paths * Add “Share this report” button * Add “Learn More” button * Make it more clear how to edit your shortcuts * Merge activity-list and new activity-dashboard, move in sidebar
59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
import React from 'react';
|
|
import { Actions, ReactDOM } from 'mailspring-exports';
|
|
import { RetinaImg } from 'mailspring-component-kit';
|
|
|
|
import ActivityList from './activity-list';
|
|
import ActivityEventStore from '../activity-event-store';
|
|
|
|
class ActivityListButton extends React.Component {
|
|
static displayName = 'ActivityListButton';
|
|
|
|
constructor() {
|
|
super();
|
|
this.state = this._getStateFromStores();
|
|
}
|
|
|
|
componentDidMount() {
|
|
this._unsub = ActivityEventStore.listen(this._onDataChanged);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this._unsub();
|
|
}
|
|
|
|
onClick = () => {
|
|
const buttonRect = ReactDOM.findDOMNode(this).getBoundingClientRect();
|
|
Actions.openPopover(<ActivityList />, { originRect: buttonRect, direction: 'down' });
|
|
};
|
|
|
|
_onDataChanged = () => {
|
|
this.setState(this._getStateFromStores());
|
|
};
|
|
|
|
_getStateFromStores() {
|
|
return {
|
|
unreadCount: ActivityEventStore.unreadCount(),
|
|
};
|
|
}
|
|
|
|
render() {
|
|
let unreadCountClass = 'unread-count';
|
|
let iconClass = 'activity-toolbar-icon';
|
|
if (this.state.unreadCount) {
|
|
unreadCountClass += ' active';
|
|
iconClass += ' unread';
|
|
}
|
|
return (
|
|
<div tabIndex={-1} className="toolbar-activity" title="View activity" onClick={this.onClick}>
|
|
<div className={unreadCountClass}>{this.state.unreadCount}</div>
|
|
<RetinaImg
|
|
name="icon-toolbar-activity.png"
|
|
className={iconClass}
|
|
mode={RetinaImg.Mode.ContentIsMask}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default ActivityListButton;
|