1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/ElectronClient/gui/Navigator.jsx
Laurent Cozic 3407a31cf6
Tools: Improve and simplify how to build the apps (#2538)
* Improving CLI build

* Improving CLI build

* Remove requirement to build the tools

* Moved Electron app one level down

* Clean up Electron build

* Moved tools to sub-dir

* Updated root script

* update root

* update root

* update root

* update root

* update root

* update root

* Updated build

* Added doc

* Update CI config

* Should not lint index.js

* Fixing jetify

* Fixed linter errors

* Fixed pod build

* Fixed Windows build
2020-02-20 22:59:18 +00:00

54 lines
1.3 KiB
JavaScript

const React = require('react');
const Component = React.Component;
const { connect } = require('react-redux');
const { bridge } = require('electron').remote.require('./bridge');
class NavigatorComponent extends Component {
UNSAFE_componentWillReceiveProps(newProps) {
if (newProps.route) {
const screenInfo = this.props.screens[newProps.route.routeName];
let windowTitle = ['Joplin'];
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 };