mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
This commit is contained in:
parent
c103bbce14
commit
d11bdf586a
@ -16,6 +16,7 @@ const DialogBox = require('react-native-dialogbox').default;
|
|||||||
const { BaseScreenComponent } = require('../base-screen');
|
const { BaseScreenComponent } = require('../base-screen');
|
||||||
const { BackButtonService } = require('../../services/back-button.js');
|
const { BackButtonService } = require('../../services/back-button.js');
|
||||||
import { AppState } from '../../utils/types';
|
import { AppState } from '../../utils/types';
|
||||||
|
const { ALL_NOTES_FILTER_ID } = require('@joplin/lib/reserved-ids.js');
|
||||||
|
|
||||||
class NotesScreenComponent extends BaseScreenComponent<any> {
|
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;
|
let buttonFolderId = this.props.selectedFolderId !== Folder.conflictFolderId() ? this.props.selectedFolderId : null;
|
||||||
if (!buttonFolderId) buttonFolderId = this.props.activeFolderId;
|
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 thisComp = this;
|
||||||
|
|
||||||
const makeActionButtonComp = () => {
|
const makeActionButtonComp = () => {
|
||||||
|
const getTargetFolderId = async () => {
|
||||||
|
if (!buttonFolderId && isAllNotes) {
|
||||||
|
return (await Folder.defaultFolder()).id;
|
||||||
|
}
|
||||||
|
return buttonFolderId;
|
||||||
|
};
|
||||||
if (addFolderNoteButtons && this.props.folders.length > 0) {
|
if (addFolderNoteButtons && this.props.folders.length > 0) {
|
||||||
const buttons = [];
|
const buttons = [];
|
||||||
buttons.push({
|
buttons.push({
|
||||||
label: _('New to-do'),
|
label: _('New to-do'),
|
||||||
onPress: () => {
|
onPress: async () => {
|
||||||
|
const folderId = await getTargetFolderId();
|
||||||
const isTodo = true;
|
const isTodo = true;
|
||||||
void this.newNoteNavigate(buttonFolderId, isTodo);
|
void this.newNoteNavigate(folderId, isTodo);
|
||||||
},
|
},
|
||||||
color: '#9b59b6',
|
color: '#9b59b6',
|
||||||
icon: 'checkbox-outline',
|
icon: 'checkbox-outline',
|
||||||
@ -241,9 +257,10 @@ class NotesScreenComponent extends BaseScreenComponent<any> {
|
|||||||
|
|
||||||
buttons.push({
|
buttons.push({
|
||||||
label: _('New note'),
|
label: _('New note'),
|
||||||
onPress: () => {
|
onPress: async () => {
|
||||||
|
const folderId = await getTargetFolderId();
|
||||||
const isTodo = false;
|
const isTodo = false;
|
||||||
void this.newNoteNavigate(buttonFolderId, isTodo);
|
void this.newNoteNavigate(folderId, isTodo);
|
||||||
},
|
},
|
||||||
color: '#9b59b6',
|
color: '#9b59b6',
|
||||||
icon: 'document',
|
icon: 'document',
|
||||||
|
@ -317,6 +317,7 @@ const appReducer = (state = appDefaultState, action: any) => {
|
|||||||
|
|
||||||
if ('smartFilterId' in action) {
|
if ('smartFilterId' in action) {
|
||||||
newState.smartFilterId = action.smartFilterId;
|
newState.smartFilterId = action.smartFilterId;
|
||||||
|
newState.selectedSmartFilterId = action.smartFilterId;
|
||||||
newState.notesParentType = 'SmartFilter';
|
newState.notesParentType = 'SmartFilter';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user