hyper/lib/containers/notifications.js

74 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-07-13 12:44:24 -08:00
import Notifications from '../components/notifications';
import {installUpdate} from '../actions/updater';
import {connect} from '../utils/plugins';
import {dismissNotification} from '../actions/notifications';
2016-07-13 12:44:24 -08:00
const NotificationsContainer = connect(
state => {
const {ui} = state;
const {notifications} = ui;
2016-07-13 12:44:24 -08:00
const state_ = {};
if (notifications.font) {
2016-07-13 21:37:46 -08:00
const fontSize = ui.fontSizeOverride || ui.fontSize;
2016-07-13 12:44:24 -08:00
Object.assign(state_, {
fontShowing: true,
fontSize,
fontText: `${fontSize}px`
});
}
if (notifications.resize) {
const cols = ui.cols;
const rows = ui.rows;
Object.assign(state_, {
resizeShowing: true,
cols,
rows
});
}
if (notifications.updates) {
Object.assign(state_, {
updateShowing: true,
updateVersion: ui.updateVersion,
2018-04-16 06:17:17 -08:00
updateNote: ui.updateNotes.split('\n')[0],
updateReleaseUrl: ui.updateReleaseUrl,
updateCanInstall: ui.updateCanInstall
2016-07-13 12:44:24 -08:00
});
} else if (notifications.message) {
Object.assign(state_, {
messageShowing: true,
messageText: ui.messageText,
messageURL: ui.messageURL,
messageDismissable: ui.messageDismissable
});
2016-07-13 12:44:24 -08:00
}
return state_;
},
dispatch => {
2016-07-13 12:44:24 -08:00
return {
onDismissFont: () => {
dispatch(dismissNotification('font'));
},
onDismissResize: () => {
dispatch(dismissNotification('resize'));
},
onDismissUpdate: () => {
dispatch(dismissNotification('updates'));
},
onDismissMessage: () => {
dispatch(dismissNotification('message'));
},
2016-07-13 12:44:24 -08:00
onUpdateInstall: () => {
dispatch(installUpdate());
}
};
}
)(Notifications, 'Notifications');
export default NotificationsContainer;