1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Desktop, Mobile, Cli: Resolves #9769: Removed ability to search by note ID to fix issue with certain plugins

This commit is contained in:
Laurent Cozic 2024-01-26 20:15:00 +00:00
parent bfb802cd09
commit 999baf4b3d
2 changed files with 23 additions and 17 deletions

View File

@ -1,7 +1,6 @@
import { setupDatabaseAndSynchronizer, db, sleep, switchClient, msleep } from '../../testing/test-utils';
import SearchEngine from './SearchEngine';
import Note from '../../models/Note';
import Folder from '../../models/Folder';
import ItemChange from '../../models/ItemChange';
import Setting from '../../models/Setting';
@ -526,21 +525,24 @@ describe('services/SearchEngine', () => {
expect((await engine.search('hello', { appendWildCards: true })).length).toBe(2);
}));
it('should search by item ID if no other result was found', (async () => {
const f1 = await Folder.save({});
const n1 = await Note.save({ title: 'hello1', parent_id: f1.id });
const n2 = await Note.save({ title: 'hello2' });
// Disabled for now:
// https://github.com/laurent22/joplin/issues/9769#issuecomment-1912459744
await engine.syncTables();
// it('should search by item ID if no other result was found', (async () => {
// const f1 = await Folder.save({});
// const n1 = await Note.save({ title: 'hello1', parent_id: f1.id });
// const n2 = await Note.save({ title: 'hello2' });
const results = await engine.search(n1.id);
expect(results.length).toBe(1);
expect(results[0].id).toBe(n1.id);
expect(results[0].title).toBe(n1.title);
expect(results[0].parent_id).toBe(n1.parent_id);
// await engine.syncTables();
expect((await engine.search(n2.id))[0].id).toBe(n2.id);
expect(await engine.search(f1.id)).toEqual([]);
}));
// const results = await engine.search(n1.id);
// expect(results.length).toBe(1);
// expect(results[0].id).toBe(n1.id);
// expect(results[0].title).toBe(n1.title);
// expect(results[0].parent_id).toBe(n1.parent_id);
// expect((await engine.search(n2.id))[0].id).toBe(n2.id);
// expect(await engine.search(f1.id)).toEqual([]);
// }));
});

View File

@ -11,7 +11,6 @@ import { ItemChangeEntity, NoteEntity, SqlQuery } from '../database/types';
import Resource from '../../models/Resource';
import JoplinDatabase from '../../JoplinDatabase';
import NoteResource from '../../models/NoteResource';
import isItemId from '../../models/utils/isItemId';
import BaseItem from '../../models/BaseItem';
import { isCallbackUrl, parseCallbackUrl } from '../../callbackUrlUtils';
const { sprintf } = require('sprintf-js');
@ -670,10 +669,15 @@ export default class SearchEngine {
if (isCallbackUrl(searchString)) {
const parsed = parseCallbackUrl(searchString);
itemId = parsed.params.id;
} else if (isItemId(searchString)) {
itemId = searchString;
}
// Disabled for now:
// https://github.com/laurent22/joplin/issues/9769#issuecomment-1912459744
// else if (isItemId(searchString)) {
// itemId = searchString;
// }
if (itemId) {
const item = await BaseItem.loadItemById(itemId);