mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
RN: Better UI to handle conflicts
This commit is contained in:
parent
dde0da571e
commit
aabc58224a
15
ReactNativeClient/lib/components/screens/folders-utils.js
Normal file
15
ReactNativeClient/lib/components/screens/folders-utils.js
Normal file
@ -0,0 +1,15 @@
|
||||
import { Folder } from 'lib/models/folder.js'
|
||||
|
||||
class FoldersScreenUtils {
|
||||
|
||||
static async refreshFolders() {
|
||||
let initialFolders = await Folder.all({ includeConflictFolder: true });
|
||||
this.dispatch({
|
||||
type: 'FOLDERS_UPDATE_ALL',
|
||||
folders: initialFolders,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { FoldersScreenUtils }
|
@ -41,22 +41,25 @@ class NotesScreenComponent extends BaseScreenComponent {
|
||||
}
|
||||
|
||||
menuOptions() {
|
||||
if (this.props.selectedFolderId == Folder.conflictFolderId()) return [];
|
||||
|
||||
return [
|
||||
{ title: _('Delete folder'), onPress: () => { this.deleteFolder_onPress(this.props.selectedFolderId); } },
|
||||
{ title: _('Edit folder'), onPress: () => { this.editFolder_onPress(this.props.selectedFolderId); } },
|
||||
{ title: _('Delete notebook'), onPress: () => { this.deleteFolder_onPress(this.props.selectedFolderId); } },
|
||||
{ title: _('Edit notebook'), onPress: () => { this.editFolder_onPress(this.props.selectedFolderId); } },
|
||||
];
|
||||
}
|
||||
|
||||
render() {
|
||||
let folder = Folder.byId(this.props.folders, this.props.selectedFolderId);
|
||||
let title = folder ? folder.title : null;
|
||||
const addFolderNoteButtons = folder.id != Folder.conflictFolderId();
|
||||
|
||||
const { navigate } = this.props.navigation;
|
||||
return (
|
||||
<View style={this.styles().screen}>
|
||||
<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 addFolderNoteButtons={true} parentFolderId={this.props.selectedFolderId}></ActionButton>
|
||||
<ActionButton addFolderNoteButtons={addFolderNoteButtons} parentFolderId={this.props.selectedFolderId}></ActionButton>
|
||||
<DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
|
||||
</View>
|
||||
);
|
||||
|
@ -63,7 +63,13 @@ class SideMenuContentComponent extends Component {
|
||||
};
|
||||
|
||||
try {
|
||||
sync.start(options);
|
||||
sync.start(options).then(async () => {
|
||||
let initialFolders = await Folder.all({ includeConflictFolder: true });
|
||||
dispatch({
|
||||
type: 'FOLDERS_UPDATE_ALL',
|
||||
folders: initialFolders,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
Log.error(error);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import { AppNav } from 'lib/components/app-nav.js'
|
||||
import { Logger } from 'lib/logger.js'
|
||||
import { Note } from 'lib/models/note.js'
|
||||
import { Folder } from 'lib/models/folder.js'
|
||||
import { FoldersScreenUtils } from 'lib/components/screens/folders-utils.js';
|
||||
import { Resource } from 'lib/models/resource.js'
|
||||
import { Tag } from 'lib/models/tag.js'
|
||||
import { NoteTag } from 'lib/models/note-tag.js'
|
||||
@ -267,6 +268,7 @@ async function initialize(dispatch, backButtonHandler) {
|
||||
|
||||
BaseModel.dispatch = dispatch;
|
||||
NotesScreenUtils.dispatch = dispatch;
|
||||
FoldersScreenUtils.dispatch = dispatch;
|
||||
BaseModel.db_ = db;
|
||||
|
||||
BaseItem.loadClass('Note', Note);
|
||||
@ -287,6 +289,8 @@ async function initialize(dispatch, backButtonHandler) {
|
||||
// await db.exec('DELETE FROM note_tags');
|
||||
// await db.exec('DELETE FROM resources');
|
||||
// await db.exec('DELETE FROM deleted_items');
|
||||
|
||||
// await db.exec('UPDATE notes SET is_conflict = 1 where id like "546f%"');
|
||||
}
|
||||
|
||||
reg.logger().info('Database is ready.');
|
||||
@ -294,12 +298,8 @@ async function initialize(dispatch, backButtonHandler) {
|
||||
await Setting.load();
|
||||
|
||||
reg.logger().info('Loading folders...');
|
||||
let initialFolders = await Folder.all();
|
||||
|
||||
dispatch({
|
||||
type: 'FOLDERS_UPDATE_ALL',
|
||||
folders: initialFolders,
|
||||
});
|
||||
await FoldersScreenUtils.refreshFolders();
|
||||
|
||||
dispatch({
|
||||
type: 'APPLICATION_LOADING_DONE',
|
||||
|
Loading…
Reference in New Issue
Block a user