mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
This commit is contained in:
parent
92dccbe98d
commit
dbb354ad10
@ -16,6 +16,7 @@ const DialogBox = require('react-native-dialogbox').default;
|
||||
const { BaseScreenComponent } = require('../base-screen');
|
||||
const { BackButtonService } = require('../../services/back-button.js');
|
||||
import { AppState } from '../../utils/types';
|
||||
const { ALL_NOTES_FILTER_ID } = require('@joplin/lib/reserved-ids.js');
|
||||
|
||||
class NotesScreenComponent extends BaseScreenComponent<any> {
|
||||
|
||||
@ -223,17 +224,32 @@ class NotesScreenComponent extends BaseScreenComponent<any> {
|
||||
let buttonFolderId = this.props.selectedFolderId !== Folder.conflictFolderId() ? this.props.selectedFolderId : null;
|
||||
if (!buttonFolderId) buttonFolderId = this.props.activeFolderId;
|
||||
|
||||
const addFolderNoteButtons = !!buttonFolderId;
|
||||
const isAllNotes =
|
||||
this.props.notesParentType === 'SmartFilter'
|
||||
&& this.props.selectedSmartFilterId === ALL_NOTES_FILTER_ID;
|
||||
|
||||
// Usually, when showing all notes, activeFolderId/selectedFolderId is set to the last
|
||||
// active folder.
|
||||
// If the app starts showing all notes, activeFolderId/selectedFolderId are
|
||||
// empty or null. As such, we need a special case to show the buttons:
|
||||
const addFolderNoteButtons = !!buttonFolderId || isAllNotes;
|
||||
const thisComp = this;
|
||||
|
||||
const makeActionButtonComp = () => {
|
||||
const getTargetFolderId = async () => {
|
||||
if (!buttonFolderId && isAllNotes) {
|
||||
return (await Folder.defaultFolder()).id;
|
||||
}
|
||||
return buttonFolderId;
|
||||
};
|
||||
if (addFolderNoteButtons && this.props.folders.length > 0) {
|
||||
const buttons = [];
|
||||
buttons.push({
|
||||
label: _('New to-do'),
|
||||
onPress: () => {
|
||||
onPress: async () => {
|
||||
const folderId = await getTargetFolderId();
|
||||
const isTodo = true;
|
||||
void this.newNoteNavigate(buttonFolderId, isTodo);
|
||||
void this.newNoteNavigate(folderId, isTodo);
|
||||
},
|
||||
color: '#9b59b6',
|
||||
icon: 'checkbox-outline',
|
||||
@ -241,9 +257,10 @@ class NotesScreenComponent extends BaseScreenComponent<any> {
|
||||
|
||||
buttons.push({
|
||||
label: _('New note'),
|
||||
onPress: () => {
|
||||
onPress: async () => {
|
||||
const folderId = await getTargetFolderId();
|
||||
const isTodo = false;
|
||||
void this.newNoteNavigate(buttonFolderId, isTodo);
|
||||
void this.newNoteNavigate(folderId, isTodo);
|
||||
},
|
||||
color: '#9b59b6',
|
||||
icon: 'document',
|
||||
|
@ -317,6 +317,7 @@ const appReducer = (state = appDefaultState, action: any) => {
|
||||
|
||||
if ('smartFilterId' in action) {
|
||||
newState.smartFilterId = action.smartFilterId;
|
||||
newState.selectedSmartFilterId = action.smartFilterId;
|
||||
newState.notesParentType = 'SmartFilter';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user