1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00

Mobile,Desktop: Fixes #10191: Do not invite user to create new notes in the trash folder (#10356)

This commit is contained in:
Henry Heino 2024-04-25 05:34:32 -07:00 committed by GitHub
parent 6aca77a0ae
commit 65c47189f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 5 deletions

View File

@ -796,6 +796,7 @@ packages/lib/commands/index.js
packages/lib/commands/openMasterPasswordDialog.js
packages/lib/commands/synchronize.js
packages/lib/components/EncryptionConfigScreen/utils.js
packages/lib/components/shared/NoteList/getEmptyFolderMessage.js
packages/lib/components/shared/config/config-shared.js
packages/lib/components/shared/config/plugins/types.js
packages/lib/components/shared/config/plugins/useOnDeleteHandler.js

1
.gitignore vendored
View File

@ -776,6 +776,7 @@ packages/lib/commands/index.js
packages/lib/commands/openMasterPasswordDialog.js
packages/lib/commands/synchronize.js
packages/lib/components/EncryptionConfigScreen/utils.js
packages/lib/components/shared/NoteList/getEmptyFolderMessage.js
packages/lib/components/shared/config/config-shared.js
packages/lib/components/shared/config/plugins/types.js
packages/lib/components/shared/config/plugins/useOnDeleteHandler.js

View File

@ -1,5 +1,4 @@
import * as React from 'react';
import { _ } from '@joplin/lib/locale';
import { useMemo, useRef, useEffect } from 'react';
import { AppState } from '../../app.reducer';
import BaseModel, { ModelType } from '@joplin/lib/BaseModel';
@ -22,6 +21,7 @@ import * as focusElementNoteList from './commands/focusElementNoteList';
import CommandService from '@joplin/lib/services/CommandService';
import useDragAndDrop from './utils/useDragAndDrop';
import { itemIsInTrash } from '@joplin/lib/services/trash';
import getEmptyFolderMessage from '@joplin/lib/components/shared/NoteList/getEmptyFolderMessage';
import Folder from '@joplin/lib/models/Folder';
const { connect } = require('react-redux');
@ -187,7 +187,7 @@ const NoteList = (props: Props) => {
const renderEmptyList = () => {
if (props.notes.length) return null;
return <div className="emptylist">{props.folders.length ? _('No notes in here. Create one by clicking on "New note".') : _('There is currently no notebook. Create one by clicking on "New notebook".')}</div>;
return <div className="emptylist">{getEmptyFolderMessage(props.folders, props.selectedFolderId)}</div>;
};
const renderFiller = (key: string, style: React.CSSProperties) => {

View File

@ -6,6 +6,7 @@ import { connect } from 'react-redux';
import { FlatList, Text, StyleSheet, Button, View } from 'react-native';
import { FolderEntity, NoteEntity } from '@joplin/lib/services/database/types';
import { AppState } from '../utils/types';
import getEmptyFolderMessage from '@joplin/lib/components/shared/NoteList/getEmptyFolderMessage';
import Folder from '@joplin/lib/models/Folder';
const { _ } = require('@joplin/lib/locale');
@ -20,7 +21,7 @@ interface NoteListProps {
items: NoteEntity[];
folders: FolderEntity[];
noteSelectionEnabled?: boolean;
selectedFolderId?: string;
selectedFolderId: string|null;
}
class NoteListComponent extends Component<NoteListProps> {
@ -102,8 +103,9 @@ class NoteListComponent extends Component<NoteListProps> {
</View>
);
} else {
const noItemMessage = _('There are currently no notes. Create one by clicking on the (+) button.');
return <Text style={this.styles().noItemMessage}>{noItemMessage}</Text>;
return <Text style={this.styles().noItemMessage}>
{getEmptyFolderMessage(this.props.folders, this.props.selectedFolderId)}
</Text>;
}
}
}
@ -117,6 +119,7 @@ const NoteList = connect((state: AppState) => {
notesSource: state.notesSource,
themeId: state.settings.theme,
noteSelectionEnabled: state.noteSelectionEnabled,
selectedFolderId: state.selectedFolderId,
};
})(NoteListComponent);

View File

@ -0,0 +1,21 @@
import { _ } from '../../../locale';
import Folder from '../../../models/Folder';
import Setting from '../../../models/Setting';
import { FolderEntity } from '../../../services/database/types';
import { getTrashFolderId, itemIsInTrash } from '../../../services/trash';
const getEmptyFolderMessage = (folders: FolderEntity[], selectedFolderId: string|null) => {
if (selectedFolderId === getTrashFolderId()) {
return _('There are no notes in the trash folder.');
} else if (selectedFolderId && itemIsInTrash(Folder.byId(folders, selectedFolderId))) {
return _('This subfolder of the trash has no notes.');
}
if (Setting.value('appType') === 'desktop') {
return _('No notes in here. Create one by clicking on "New note".');
} else {
return _('There are currently no notes. Create one by clicking on the (+) button.');
}
};
export default getEmptyFolderMessage;