mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
Various RN changes
This commit is contained in:
parent
d92f1c7eba
commit
bde42a80b6
@ -90,8 +90,8 @@ android {
|
||||
applicationId "net.cozic.joplin"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 22
|
||||
versionCode 10
|
||||
versionName "0.8.8"
|
||||
versionCode 11
|
||||
versionName "0.8.9"
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "x86"
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import { Log } from 'lib/log.js'
|
||||
import { Folder } from 'lib/models/folder.js'
|
||||
import { BaseModel } from 'lib/base-model.js'
|
||||
import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js'
|
||||
|
||||
class FolderScreenComponent extends React.Component {
|
||||
|
||||
@ -51,11 +52,7 @@ class FolderScreenComponent extends React.Component {
|
||||
this.originalFolder = await Folder.save(toSave);
|
||||
this.setState({ folder: this.originalFolder });
|
||||
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
routeName: 'Notes',
|
||||
folderId: toSave.id,
|
||||
});
|
||||
await NotesScreenUtils.openDefaultNoteList();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Note } from 'lib/models/note.js'
|
||||
import { Folder } from 'lib/models/folder.js'
|
||||
import { Log } from 'lib/log.js'
|
||||
|
||||
class NotesScreenUtils {
|
||||
@ -20,6 +21,18 @@ class NotesScreenUtils {
|
||||
});
|
||||
}
|
||||
|
||||
static async openDefaultNoteList() {
|
||||
const selectedFolder = await Folder.defaultFolder();
|
||||
if (selectedFolder) {
|
||||
this.openNoteList(selectedFolder.id);
|
||||
} else {
|
||||
this.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
routeName: 'Loading',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { NotesScreenUtils }
|
@ -8,6 +8,8 @@ import { ScreenHeader } from 'lib/components/screen-header.js';
|
||||
import { MenuOption, Text } from 'react-native-popup-menu';
|
||||
import { _ } from 'lib/locale.js';
|
||||
import { ActionButton } from 'lib/components/action-button.js';
|
||||
import { dialogs } from 'lib/dialogs.js';
|
||||
import { NotesScreenUtils } from 'lib/components/screens/notes-utils.js'
|
||||
import DialogBox from 'react-native-dialogbox';
|
||||
|
||||
class NotesScreenComponent extends React.Component {
|
||||
@ -17,16 +19,15 @@ class NotesScreenComponent extends React.Component {
|
||||
}
|
||||
|
||||
deleteFolder_onPress(folderId) {
|
||||
let ok = confirm(_('Delete notebook?'));
|
||||
if (!ok) return;
|
||||
dialogs.confirm(this, _('Delete notebook?')).then((ok) => {
|
||||
if (!ok) return;
|
||||
|
||||
Folder.delete(folderId).then(() => {
|
||||
this.props.dispatch({
|
||||
type: 'Navigation/NAVIGATE',
|
||||
routeName: 'Folders',
|
||||
|
||||
Folder.delete(folderId).then(() => {
|
||||
return NotesScreenUtils.openDefaultNoteList();
|
||||
}).catch((error) => {
|
||||
alert(error.message);
|
||||
});
|
||||
}).catch((error) => {
|
||||
alert(error.message);
|
||||
});
|
||||
}
|
||||
|
||||
@ -49,12 +50,16 @@ class NotesScreenComponent extends React.Component {
|
||||
let folder = Folder.byId(this.props.folders, this.props.selectedFolderId);
|
||||
let title = folder ? folder.title : null;
|
||||
|
||||
console.info('FOLDER', folder);
|
||||
|
||||
const { navigate } = this.props.navigation;
|
||||
return (
|
||||
<View style={{flex: 1}}>
|
||||
<ScreenHeader title={title} navState={this.props.navigation.state} menuOptions={this.menuOptions()} />
|
||||
<NoteList noItemMessage={_('There are currently no notes. Create one by clicking on the (+) button.')} style={{flex: 1}}/>
|
||||
<ActionButton parentFolderId={this.props.selectedFolderId}></ActionButton>
|
||||
|
||||
<DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
32
ReactNativeClient/lib/dialogs.js
Normal file
32
ReactNativeClient/lib/dialogs.js
Normal file
@ -0,0 +1,32 @@
|
||||
import DialogBox from 'react-native-dialogbox';
|
||||
|
||||
// Add this at the bottom of the component:
|
||||
//
|
||||
// <DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
|
||||
|
||||
let dialogs = {};
|
||||
|
||||
dialogs.confirm = (parentComponent, message) => {
|
||||
if (!'dialogbox' in parentComponent) throw new Error('A "dialogbox" component must be defined on the parent component!');
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
parentComponent.dialogbox.confirm({
|
||||
content: message,
|
||||
|
||||
ok: {
|
||||
callback: () => {
|
||||
resolve(true);
|
||||
}
|
||||
},
|
||||
|
||||
cancel: {
|
||||
callback: () => {
|
||||
resolve(false);
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export { dialogs };
|
@ -168,7 +168,7 @@ class OneDriveApi {
|
||||
}
|
||||
} catch (error) {
|
||||
// TEMPORARY: To try to find where uncaught error comes from
|
||||
let error = new Error('OneDrive API caught: ' + error.message);
|
||||
let error = new Error('OneDrive API caught: ' + JSON.stringify(error));
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
@ -283,10 +283,7 @@ async function initialize(dispatch, backButtonHandler) {
|
||||
type: 'APPLICATION_LOADING_DONE',
|
||||
});
|
||||
|
||||
if (initialFolders.length) {
|
||||
const selectedFolder = await Folder.defaultFolder();
|
||||
if (selectedFolder) NotesScreenUtils.openNoteList(selectedFolder.id);
|
||||
}
|
||||
await NotesScreenUtils.openDefaultNoteList();
|
||||
} catch (error) {
|
||||
reg.logger().error('Initialization error:', error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user