mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
Mobile: Added 'All notes' screen; Cleaned up header bar buttons; Removed 'body' from note preview object to improve memory usage
This commit is contained in:
parent
4d92187327
commit
da21580785
@ -124,7 +124,7 @@ class ScreenHeaderComponent extends Component {
|
||||
titleText: {
|
||||
flex: 1,
|
||||
textAlignVertical: 'center',
|
||||
marginLeft: 0,
|
||||
marginLeft: 10,
|
||||
color: theme.raisedHighlightedColor,
|
||||
fontWeight: 'bold',
|
||||
fontSize: theme.fontSize,
|
||||
@ -376,10 +376,11 @@ class ScreenHeaderComponent extends Component {
|
||||
const showSideMenuButton = this.props.showSideMenuButton !== false && !this.props.noteSelectionEnabled;
|
||||
const showSearchButton = this.props.showSearchButton !== false && !this.props.noteSelectionEnabled;
|
||||
const showContextMenuButton = this.props.showContextMenuButton !== false;
|
||||
const showBackButton = this.props.showBackButton !== false;
|
||||
|
||||
const titleComp = createTitleComponent();
|
||||
const sideMenuComp = !showSideMenuButton ? null : sideMenuButton(this.styles(), () => this.sideMenuButton_press());
|
||||
const backButtonComp = backButton(this.styles(), () => this.backButton_press(), !this.props.historyCanGoBack);
|
||||
const backButtonComp = !showBackButton ? null : backButton(this.styles(), () => this.backButton_press(), !this.props.historyCanGoBack);
|
||||
const searchButtonComp = !showSearchButton ? null : searchButton(this.styles(), () => this.searchButton_press());
|
||||
const deleteButtonComp = this.props.noteSelectionEnabled ? deleteButton(this.styles(), () => this.deleteButton_press()) : null;
|
||||
const sortButtonComp = this.props.sortButton_press ? sortButton(this.styles(), () => this.props.sortButton_press()) : null;
|
||||
|
@ -112,6 +112,8 @@ class FolderScreenComponent extends BaseScreenComponent {
|
||||
showSaveButton={true}
|
||||
saveButtonDisabled={saveButtonDisabled}
|
||||
onSaveButtonPress={() => this.saveFolderButton_press()}
|
||||
showSideMenuButton={false}
|
||||
showSearchButton={false}
|
||||
/>
|
||||
<TextInput underlineColorAndroid={theme.strongDividerColor} selectionColor={theme.textSelectionColor} style={this.styles().textInput} autoFocus={true} value={this.state.folder.title} onChangeText={(text) => this.title_changeText(text)} />
|
||||
<dialogs.DialogBox ref={dialogbox => { this.dialogbox = dialogbox }}/>
|
||||
|
@ -85,6 +85,7 @@ class NotesScreenComponent extends BaseScreenComponent {
|
||||
if (newProps.notesOrder !== this.props.notesOrder ||
|
||||
newProps.selectedFolderId != this.props.selectedFolderId ||
|
||||
newProps.selectedTagId != this.props.selectedTagId ||
|
||||
newProps.selectedSmartFilterId != this.props.selectedSmartFilterId ||
|
||||
newProps.notesParentType != this.props.notesParentType) {
|
||||
await this.refreshNotes(newProps);
|
||||
}
|
||||
@ -111,10 +112,12 @@ class NotesScreenComponent extends BaseScreenComponent {
|
||||
if (source == props.notesSource) return;
|
||||
|
||||
let notes = [];
|
||||
if (props.notesParentType == 'Folder') {
|
||||
if (props.notesParentType === 'Folder') {
|
||||
notes = await Note.previews(props.selectedFolderId, options);
|
||||
} else {
|
||||
} else if (props.notesParentType === 'Tag') {
|
||||
notes = await Tag.notes(props.selectedTagId, options);
|
||||
} else if (props.notesParentType === 'SmartFilter') {
|
||||
notes = await Note.previews(null, options);
|
||||
}
|
||||
|
||||
this.props.dispatch({
|
||||
@ -172,6 +175,8 @@ class NotesScreenComponent extends BaseScreenComponent {
|
||||
output = Folder.byId(props.folders, props.selectedFolderId);
|
||||
} else if (props.notesParentType == 'Tag') {
|
||||
output = Tag.byId(props.tags, props.selectedTagId);
|
||||
} else if (props.notesParentType == 'SmartFilter') {
|
||||
output = { id: this.props.selectedSmartFilterId, title: _('All notes') };
|
||||
} else {
|
||||
return null;
|
||||
throw new Error('Invalid parent type: ' + props.notesParentType);
|
||||
@ -209,6 +214,7 @@ class NotesScreenComponent extends BaseScreenComponent {
|
||||
<View style={rootStyle}>
|
||||
<ScreenHeader
|
||||
title={title}
|
||||
showBackButton={false}
|
||||
menuOptions={this.menuOptions()}
|
||||
parentComponent={thisComp}
|
||||
sortButton_press={this.sortButton_press}
|
||||
@ -233,6 +239,7 @@ const NotesScreen = connect(
|
||||
selectedFolderId: state.selectedFolderId,
|
||||
selectedNoteIds: state.selectedNoteIds,
|
||||
selectedTagId: state.selectedTagId,
|
||||
selectedSmartFilterId: state.selectedSmartFilterId,
|
||||
notesParentType: state.notesParentType,
|
||||
notes: state.notes,
|
||||
notesSource: state.notesSource,
|
||||
|
@ -166,6 +166,8 @@ class SearchScreenComponent extends BaseScreenComponent {
|
||||
enabled: this.props.noteSelectionEnabled,
|
||||
mustSelect: true,
|
||||
}}
|
||||
showSideMenuButton={false}
|
||||
showSearchButton={false}
|
||||
/>
|
||||
<View style={this.styles().body}>
|
||||
<View style={this.styles().searchContainer}>
|
||||
|
@ -86,16 +86,28 @@ class SideMenuContentComponent extends Component {
|
||||
}
|
||||
|
||||
folder_press(folder) {
|
||||
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||
if (folder === 'all') {
|
||||
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||
|
||||
this.props.dispatch({
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Notes',
|
||||
folderId: folder.id,
|
||||
});
|
||||
this.props.dispatch({
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Notes',
|
||||
smartFilterId: 'c3176726992c11e9ac940492261af972',
|
||||
});
|
||||
} else {
|
||||
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
|
||||
|
||||
this.props.dispatch({
|
||||
type: 'NAV_GO',
|
||||
routeName: 'Notes',
|
||||
folderId: folder.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async folder_longPress(folder) {
|
||||
if (folder === 'all') return;
|
||||
|
||||
const buttons = [];
|
||||
|
||||
Alert.alert(
|
||||
@ -201,20 +213,24 @@ class SideMenuContentComponent extends Component {
|
||||
const iconWrapperStyle = { paddingLeft: 10, paddingRight: 10 };
|
||||
if (selected) iconWrapperStyle.backgroundColor = theme.selectedColor;
|
||||
|
||||
const iconName = this.props.collapsedFolderIds.indexOf(folder.id) >= 0 ? 'md-arrow-dropdown' : 'md-arrow-dropup';
|
||||
const iconComp = <Icon name={iconName} style={this.styles().folderIcon} />
|
||||
let iconWrapper = null;
|
||||
|
||||
const iconWrapper = !hasChildren ? null : (
|
||||
<TouchableOpacity style={iconWrapperStyle} folderid={folder.id} onPress={() => { if (hasChildren) this.folder_togglePress(folder) }}>
|
||||
{ iconComp }
|
||||
</TouchableOpacity>
|
||||
);
|
||||
if (folder !== 'all') {
|
||||
const iconName = this.props.collapsedFolderIds.indexOf(folder.id) >= 0 ? 'md-arrow-dropdown' : 'md-arrow-dropup';
|
||||
const iconComp = <Icon name={iconName} style={this.styles().folderIcon} />
|
||||
|
||||
iconWrapper = !hasChildren ? null : (
|
||||
<TouchableOpacity style={iconWrapperStyle} folderid={folder.id} onPress={() => { if (hasChildren) this.folder_togglePress(folder) }}>
|
||||
{ iconComp }
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View key={folder.id} style={{ flex: 1, flexDirection: 'row' }}>
|
||||
<View key={folder === 'all' ? folder : folder.id} style={{ flex: 1, flexDirection: 'row' }}>
|
||||
<TouchableOpacity style={{ flex: 1 }} onPress={() => { this.folder_press(folder) }} onLongPress={() => { this.folder_longPress(folder) }}>
|
||||
<View style={folderButtonStyle}>
|
||||
<Text numberOfLines={1} style={this.styles().folderButtonText}>{Folder.displayTitle(folder)}</Text>
|
||||
<Text numberOfLines={1} style={this.styles().folderButtonText}>{folder === 'all' ? _('All notes') : Folder.displayTitle(folder)}</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
{ iconWrapper }
|
||||
@ -297,6 +313,10 @@ class SideMenuContentComponent extends Component {
|
||||
// using padding. So instead creating blank elements for padding bottom and top.
|
||||
items.push(<View style={{ height: globalStyle.marginTop }} key='bottom_top_hack'/>);
|
||||
|
||||
items.push(this.renderFolderItem('all', this.props.notesParentType === 'SmartFilter', false, 0));
|
||||
|
||||
items.push(this.makeDivider('divider_all'));
|
||||
|
||||
if (this.props.folders.length) {
|
||||
const result = shared.renderFolders(this.props, this.renderFolderItem);
|
||||
const folderItems = result.items;
|
||||
|
@ -194,6 +194,10 @@ class JoplinDatabase extends Database {
|
||||
queries.push('DELETE FROM settings WHERE key="sync.5.context"');
|
||||
queries.push('DELETE FROM settings WHERE key="sync.6.context"');
|
||||
queries.push('DELETE FROM settings WHERE key="sync.7.context"');
|
||||
|
||||
queries.push('DELETE FROM settings WHERE key="revisionService.lastProcessedChangeId"');
|
||||
queries.push('DELETE FROM settings WHERE key="resourceService.lastProcessedChangeId"');
|
||||
queries.push('DELETE FROM settings WHERE key="searchEngine.lastProcessedChangeId"');
|
||||
|
||||
await this.transactionExecBatch(queries);
|
||||
}
|
||||
|
@ -250,7 +250,8 @@ class Note extends BaseItem {
|
||||
}
|
||||
|
||||
static previewFields() {
|
||||
return ['id', 'title', 'body', 'is_todo', 'todo_completed', 'parent_id', 'updated_time', 'user_updated_time', 'user_created_time', 'encryption_applied'];
|
||||
// return ['id', 'title', 'body', 'is_todo', 'todo_completed', 'parent_id', 'updated_time', 'user_updated_time', 'user_created_time', 'encryption_applied'];
|
||||
return ['id', 'title', 'is_todo', 'todo_completed', 'parent_id', 'updated_time', 'user_updated_time', 'user_created_time', 'encryption_applied'];
|
||||
}
|
||||
|
||||
static previewFieldsSql(fields = null) {
|
||||
|
@ -249,6 +249,11 @@ const appReducer = (state = appDefaultState, action) => {
|
||||
newState.notesParentType = 'Tag';
|
||||
}
|
||||
|
||||
if ('smartFilterId' in action) {
|
||||
newState.smartFilterId = action.smartFilterId;
|
||||
newState.notesParentType = 'SmartFilter';
|
||||
}
|
||||
|
||||
if ('itemType' in action) {
|
||||
newState.selectedItemType = action.itemType;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user