mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Improved app startup
This commit is contained in:
parent
72c4ed8453
commit
a270a345d3
@ -22,23 +22,15 @@ class WelcomeScreenComponent extends BaseScreenComponent {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.props.loading) {
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<Text>Loading...</Text>
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
let message = this.props.folders.length ? _('Click on the (+) button to create a new note or notebook. Click on the side menu to access your existing notebooks.') : _('You currently have no notebook. Create one by clicking on (+) button.');
|
||||
let message = this.props.folders.length ? _('Click on the (+) button to create a new note or notebook. Click on the side menu to access your existing notebooks.') : _('You currently have no notebook. Create one by clicking on (+) button.');
|
||||
|
||||
return (
|
||||
<View style={this.styles().screen} >
|
||||
<ScreenHeader title={_('Welcome')}/>
|
||||
<Text style={styles.message}>{message}</Text>
|
||||
<ActionButton addFolderNoteButtons={true}/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<View style={this.styles().screen} >
|
||||
<ScreenHeader title={_('Welcome')}/>
|
||||
<Text style={styles.message}>{message}</Text>
|
||||
<ActionButton addFolderNoteButtons={true}/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@ -46,7 +38,6 @@ class WelcomeScreenComponent extends BaseScreenComponent {
|
||||
const WelcomeScreen = connect(
|
||||
(state) => {
|
||||
return {
|
||||
loading: state.loading,
|
||||
folders: state.folders,
|
||||
};
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ let defaultState = {
|
||||
selectedItemType: 'note',
|
||||
showSideMenu: false,
|
||||
screens: {},
|
||||
loading: true,
|
||||
historyCanGoBack: false,
|
||||
notesOrder: [
|
||||
{ by: 'updated_time', dir: 'DESC' },
|
||||
@ -56,6 +55,7 @@ let defaultState = {
|
||||
syncReport: {},
|
||||
searchQuery: '',
|
||||
settings: {},
|
||||
appState: 'starting',
|
||||
};
|
||||
|
||||
const initialRoute = {
|
||||
@ -188,13 +188,6 @@ const reducer = (state = defaultState, action) => {
|
||||
newState.historyCanGoBack = !!navHistory.length;
|
||||
break;
|
||||
|
||||
// Replace all the notes with the provided array
|
||||
case 'APPLICATION_LOADING_DONE':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
newState.loading = false;
|
||||
break;
|
||||
|
||||
case 'SETTINGS_UPDATE_ALL':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
@ -348,6 +341,11 @@ const reducer = (state = defaultState, action) => {
|
||||
newState = Object.assign({}, state);
|
||||
newState.searchQuery = action.query.trim();
|
||||
|
||||
case 'SET_APP_STATE':
|
||||
|
||||
newState = Object.assign({}, state);
|
||||
newState.appState = action.state;
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
error.message = 'In reducer: ' + error.message + ' Action: ' + JSON.stringify(action);
|
||||
@ -383,15 +381,9 @@ const generalMiddleware = store => next => async (action) => {
|
||||
|
||||
let store = createStore(reducer, applyMiddleware(generalMiddleware));
|
||||
|
||||
let initializationState_ = 'waiting';
|
||||
|
||||
async function initialize(dispatch, backButtonHandler) {
|
||||
if (initializationState_ != 'waiting') return;
|
||||
|
||||
shimInit();
|
||||
|
||||
initializationState_ = 'in_progress';
|
||||
|
||||
Setting.setConstant('env', __DEV__ ? 'dev' : 'prod');
|
||||
Setting.setConstant('appId', 'net.cozic.joplin');
|
||||
Setting.setConstant('appType', 'mobile');
|
||||
@ -476,10 +468,6 @@ async function initialize(dispatch, backButtonHandler) {
|
||||
tags: tags,
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: 'APPLICATION_LOADING_DONE',
|
||||
});
|
||||
|
||||
let folderId = Setting.value('activeFolderId');
|
||||
let folder = await Folder.load(folderId);
|
||||
|
||||
@ -513,8 +501,6 @@ async function initialize(dispatch, backButtonHandler) {
|
||||
reg.scheduleSync();
|
||||
}
|
||||
|
||||
initializationState_ = 'done';
|
||||
|
||||
reg.logger().info('Application initialized');
|
||||
}
|
||||
|
||||
@ -526,7 +512,19 @@ class AppComponent extends React.Component {
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
await initialize(this.props.dispatch, this.backButtonHandler.bind(this));
|
||||
if (this.props.appState == 'starting') {
|
||||
this.props.dispatch({
|
||||
type: 'SET_APP_STATE',
|
||||
state: 'initializing',
|
||||
});
|
||||
|
||||
await initialize(this.props.dispatch, this.backButtonHandler.bind(this));
|
||||
|
||||
this.props.dispatch({
|
||||
type: 'SET_APP_STATE',
|
||||
state: 'ready',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
backButtonHandler() {
|
||||
@ -559,6 +557,8 @@ class AppComponent extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.props.appState != 'ready') return null;
|
||||
|
||||
const sideMenuContent = <SideMenuContent/>;
|
||||
|
||||
const appNavInit = {
|
||||
@ -588,6 +588,7 @@ const mapStateToProps = (state) => {
|
||||
historyCanGoBack: state.historyCanGoBack,
|
||||
showSideMenu: state.showSideMenu,
|
||||
syncStarted: state.syncStarted,
|
||||
appState: state.appState,
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user