diff --git a/.eslintignore b/.eslintignore index 75b4314a2..165384b7e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -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 diff --git a/.gitignore b/.gitignore index dbc43d626..01090396f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/packages/app-desktop/gui/NoteList/NoteList2.tsx b/packages/app-desktop/gui/NoteList/NoteList2.tsx index c3ad5ca06..997a7351b 100644 --- a/packages/app-desktop/gui/NoteList/NoteList2.tsx +++ b/packages/app-desktop/gui/NoteList/NoteList2.tsx @@ -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
{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".')}
; + return
{getEmptyFolderMessage(props.folders, props.selectedFolderId)}
; }; const renderFiller = (key: string, style: React.CSSProperties) => { diff --git a/packages/app-mobile/components/NoteList.tsx b/packages/app-mobile/components/NoteList.tsx index 8376675f7..e5a6b9dd8 100644 --- a/packages/app-mobile/components/NoteList.tsx +++ b/packages/app-mobile/components/NoteList.tsx @@ -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 { @@ -102,8 +103,9 @@ class NoteListComponent extends Component { ); } else { - const noItemMessage = _('There are currently no notes. Create one by clicking on the (+) button.'); - return {noItemMessage}; + return + {getEmptyFolderMessage(this.props.folders, this.props.selectedFolderId)} + ; } } } @@ -117,6 +119,7 @@ const NoteList = connect((state: AppState) => { notesSource: state.notesSource, themeId: state.settings.theme, noteSelectionEnabled: state.noteSelectionEnabled, + selectedFolderId: state.selectedFolderId, }; })(NoteListComponent); diff --git a/packages/lib/components/shared/NoteList/getEmptyFolderMessage.ts b/packages/lib/components/shared/NoteList/getEmptyFolderMessage.ts new file mode 100644 index 000000000..b4e14c14e --- /dev/null +++ b/packages/lib/components/shared/NoteList/getEmptyFolderMessage.ts @@ -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;