1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00

Mobile: Fixes #9328: Fix new note/to-do buttons not visible on app startup in some cases (#9329)

This commit is contained in:
Henry Heino 2023-11-19 02:43:57 -08:00 committed by GitHub
parent 92dccbe98d
commit dbb354ad10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 5 deletions

View File

@ -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',

View File

@ -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';
}