mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-30 10:36:35 +02:00
a0ead2c48e
This reverts commit c79c9c4c2f
.
Reason: Still need to discuss how it should be implemented. Ref:
https://discourse.joplinapp.org/t/testing-v1-8-2-title-bar-path-format-minor/16937/10
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
const React = require('react');
|
|
const Component = React.Component;
|
|
const Setting = require('@joplin/lib/models/Setting').default;
|
|
const { connect } = require('react-redux');
|
|
const bridge = require('electron').remote.require('./bridge').default;
|
|
|
|
class NavigatorComponent extends Component {
|
|
UNSAFE_componentWillReceiveProps(newProps) {
|
|
if (newProps.route) {
|
|
const screenInfo = this.props.screens[newProps.route.routeName];
|
|
const devMarker = Setting.value('env') === 'dev' ? ' (DEV)' : '';
|
|
const windowTitle = [`Joplin${devMarker}`];
|
|
if (screenInfo.title) {
|
|
windowTitle.push(screenInfo.title());
|
|
}
|
|
this.updateWindowTitle(windowTitle.join(' - '));
|
|
}
|
|
}
|
|
|
|
updateWindowTitle(title) {
|
|
try {
|
|
if (bridge().window()) bridge().window().setTitle(title);
|
|
} catch (error) {
|
|
console.warn('updateWindowTitle', error);
|
|
}
|
|
}
|
|
|
|
render() {
|
|
if (!this.props.route) throw new Error('Route must not be null');
|
|
|
|
const route = this.props.route;
|
|
const screenProps = route.props ? route.props : {};
|
|
const screenInfo = this.props.screens[route.routeName];
|
|
const Screen = screenInfo.screen;
|
|
|
|
const screenStyle = {
|
|
width: this.props.style.width,
|
|
height: this.props.style.height,
|
|
};
|
|
|
|
return (
|
|
<div style={this.props.style}>
|
|
<Screen style={screenStyle} {...screenProps} />
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
const Navigator = connect(state => {
|
|
return {
|
|
route: state.route,
|
|
};
|
|
})(NavigatorComponent);
|
|
|
|
module.exports = { Navigator };
|