2017-09-27 02:42:18 +08:00
|
|
|
import { OnlineStatusStore, React, PropTypes, Actions } from 'mailspring-exports';
|
2017-09-27 02:46:00 +08:00
|
|
|
import { Notification, ListensToFluxStore } from 'mailspring-component-kit';
|
2017-02-15 16:31:27 +08:00
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
function OfflineNotification({ isOnline, retryingInSeconds }) {
|
2017-02-15 16:31:27 +08:00
|
|
|
if (isOnline) {
|
2017-09-27 02:33:08 +08:00
|
|
|
return false;
|
2017-02-15 16:31:27 +08:00
|
|
|
}
|
2017-09-27 02:33:08 +08:00
|
|
|
const subtitle = retryingInSeconds
|
|
|
|
? `Retrying in ${retryingInSeconds} second${retryingInSeconds > 1 ? 's' : ''}`
|
|
|
|
: `Retrying now...`;
|
2017-02-15 16:31:27 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Notification
|
|
|
|
className="offline"
|
2017-09-06 04:37:40 +08:00
|
|
|
title="Mailspring is offline"
|
2017-02-15 16:31:27 +08:00
|
|
|
subtitle={subtitle}
|
|
|
|
priority="5"
|
|
|
|
icon="volstead-offline.png"
|
2017-09-27 02:33:08 +08:00
|
|
|
actions={[
|
|
|
|
{
|
|
|
|
id: 'try_now',
|
|
|
|
label: 'Try now',
|
|
|
|
fn: () => Actions.checkOnlineStatus(),
|
|
|
|
},
|
|
|
|
]}
|
2017-02-15 16:31:27 +08:00
|
|
|
/>
|
2017-09-27 02:33:08 +08:00
|
|
|
);
|
2017-02-15 16:31:27 +08:00
|
|
|
}
|
2017-09-27 02:33:08 +08:00
|
|
|
OfflineNotification.displayName = 'OfflineNotification';
|
2017-02-15 16:31:27 +08:00
|
|
|
OfflineNotification.propTypes = {
|
2017-09-27 02:33:08 +08:00
|
|
|
isOnline: PropTypes.bool,
|
|
|
|
retryingInSeconds: PropTypes.number,
|
|
|
|
};
|
2017-02-15 16:31:27 +08:00
|
|
|
|
|
|
|
export default ListensToFluxStore(OfflineNotification, {
|
|
|
|
stores: [OnlineStatusStore],
|
|
|
|
getStateFromStores() {
|
|
|
|
return {
|
|
|
|
isOnline: OnlineStatusStore.isOnline(),
|
|
|
|
retryingInSeconds: OnlineStatusStore.retryingInSeconds(),
|
2017-09-27 02:33:08 +08:00
|
|
|
};
|
2017-02-15 16:31:27 +08:00
|
|
|
},
|
2017-09-27 02:33:08 +08:00
|
|
|
});
|