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

Desktop: Fixes #10668: Tags and Delete note not being available on Search and on All Notes list (#10729)

This commit is contained in:
pedr 2024-08-02 13:44:30 -03:00 committed by GitHub
parent f69dffcf23
commit 5c8be448ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 78 additions and 2 deletions

View File

@ -1050,6 +1050,7 @@ packages/lib/services/commands/commandsToMarkdownTable.js
packages/lib/services/commands/focusEditorIfEditorCommand.js packages/lib/services/commands/focusEditorIfEditorCommand.js
packages/lib/services/commands/isEditorCommand.js packages/lib/services/commands/isEditorCommand.js
packages/lib/services/commands/propsHaveChanged.js packages/lib/services/commands/propsHaveChanged.js
packages/lib/services/commands/stateToWhenClauseContext.test.js
packages/lib/services/commands/stateToWhenClauseContext.js packages/lib/services/commands/stateToWhenClauseContext.js
packages/lib/services/contextkey/contextkey.js packages/lib/services/contextkey/contextkey.js
packages/lib/services/database/addMigrationFile.js packages/lib/services/database/addMigrationFile.js

1
.gitignore vendored
View File

@ -1028,6 +1028,7 @@ packages/lib/services/commands/commandsToMarkdownTable.js
packages/lib/services/commands/focusEditorIfEditorCommand.js packages/lib/services/commands/focusEditorIfEditorCommand.js
packages/lib/services/commands/isEditorCommand.js packages/lib/services/commands/isEditorCommand.js
packages/lib/services/commands/propsHaveChanged.js packages/lib/services/commands/propsHaveChanged.js
packages/lib/services/commands/stateToWhenClauseContext.test.js
packages/lib/services/commands/stateToWhenClauseContext.js packages/lib/services/commands/stateToWhenClauseContext.js
packages/lib/services/contextkey/contextkey.js packages/lib/services/contextkey/contextkey.js
packages/lib/services/database/addMigrationFile.js packages/lib/services/database/addMigrationFile.js

View File

@ -0,0 +1,74 @@
import { State } from '../../reducer';
import { getTrashFolderId } from '../trash';
import stateToWhenClauseContext from './stateToWhenClauseContext';
describe('stateToWhenClauseContext', () => {
it('should be in trash if selected note has been deleted and selected folder is trash', async () => {
const applicationState = {
selectedNoteIds: ['1'],
selectedFolderId: getTrashFolderId(),
notes: [
{ id: '1', deleted_time: 1722567036580 },
],
folders: [],
} as State;
const resultingState = stateToWhenClauseContext(applicationState);
expect(resultingState.inTrash).toBe(true);
});
it('should NOT be in trash if selected note has not been deleted', async () => {
const applicationState = {
selectedNoteIds: ['1'],
selectedFolderId: getTrashFolderId(),
notes: [
{ id: '1', deleted_time: 0 },
],
folders: [],
} as State;
const resultingState = stateToWhenClauseContext(applicationState);
expect(resultingState.inTrash).toBe(false);
});
it('should NOT be in trash if selected folder is not trash', async () => {
const applicationState = {
selectedNoteIds: ['1'],
selectedFolderId: 'any-other-folder',
notes: [
{ id: '1', deleted_time: 1722567036580 },
],
folders: [],
} as State;
const resultingState = stateToWhenClauseContext(applicationState);
expect(resultingState.inTrash).toBe(false);
});
it('should be in trash if command folder is deleted', async () => {
const applicationState = {
notes: [],
folders: [
{ id: '1', deleted_time: 1722567036580, share_id: '', parent_id: '' },
],
} as State;
const resultingState = stateToWhenClauseContext(applicationState, { commandFolderId: '1' });
expect(resultingState.inTrash).toBe(true);
});
it('should NOT be in trash if command folder is not deleted', async () => {
const applicationState = {
notes: [],
folders: [
{ id: '1', deleted_time: 0, share_id: '', parent_id: '' },
],
} as State;
const resultingState = stateToWhenClauseContext(applicationState, { commandFolderId: '1' });
expect(resultingState.inTrash).toBe(false);
});
});

View File

@ -68,7 +68,7 @@ export default function stateToWhenClauseContext(state: State, options: WhenClau
// Current location // Current location
inConflictFolder: state.selectedFolderId === Folder.conflictFolderId(), inConflictFolder: state.selectedFolderId === Folder.conflictFolderId(),
inTrash: state.selectedFolderId === getTrashFolderId() || commandFolder && !!commandFolder.deleted_time, inTrash: !!((state.selectedFolderId === getTrashFolderId() && !!selectedNote?.deleted_time) || commandFolder && !!commandFolder.deleted_time),
// Note selection // Note selection
oneNoteSelected: !!selectedNote, oneNoteSelected: !!selectedNote,
@ -101,7 +101,7 @@ export default function stateToWhenClauseContext(state: State, options: WhenClau
folderIsShared: commandFolder ? !!commandFolder.share_id : false, folderIsShared: commandFolder ? !!commandFolder.share_id : false,
folderIsDeleted: commandFolder ? !!commandFolder.deleted_time : false, folderIsDeleted: commandFolder ? !!commandFolder.deleted_time : false,
folderIsTrash: commandFolder ? commandFolder.id === getTrashFolderId() : false, folderIsTrash: commandFolder ? commandFolder.id === getTrashFolderId() : false,
folderIsReadOnly: commandFolder ? itemIsReadOnlySync(ModelType.Note, ItemChange.SOURCE_UNSPECIFIED, commandFolder as ItemSlice, settings['sync.userId'], state.shareService) : false, folderIsReadOnly: commandFolder ? itemIsReadOnlySync(ModelType.Folder, ItemChange.SOURCE_UNSPECIFIED, commandFolder as ItemSlice, settings['sync.userId'], state.shareService) : false,
joplinServerConnected: [9, 10].includes(settings['sync.target']), joplinServerConnected: [9, 10].includes(settings['sync.target']),
joplinCloudAccountType: settings['sync.target'] === 10 ? settings['sync.10.accountType'] : 0, joplinCloudAccountType: settings['sync.target'] === 10 ? settings['sync.10.accountType'] : 0,