mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-23 07:19:50 -04:00
more fixes for note search
This commit is contained in:
parent
78a349fb0f
commit
caf3ef2d30
@ -157,7 +157,7 @@ export class AppService extends createStateService(reducer, initialState) {
|
||||
async updateCards(queries: IStorable<readonly DataReference[]>) {
|
||||
const cards: CardItem[] = [];
|
||||
for (const q of queries.value) {
|
||||
const card = await this.getCardByQuery(q.qry, q.type);
|
||||
const card = await this.getCardByQuery(q.qry.trim(), q.type);
|
||||
cards.push(card);
|
||||
}
|
||||
this.dispatch(
|
||||
@ -170,9 +170,19 @@ export class AppService extends createStateService(reducer, initialState) {
|
||||
}
|
||||
|
||||
private async getCardByQuery(qry: string, type?: CardType): Promise<CardItem> {
|
||||
if (qry.startsWith('note:') || (type !== undefined && type === CardType.Note)) {
|
||||
const id = qry.replace('note:', '');
|
||||
const data = this.getState().notes.value.find((o) => o.id === id);
|
||||
if (qry.startsWith('note:')) {
|
||||
const q = qry.toLocaleLowerCase().trim().replace('note:', '');
|
||||
const data = this.getState().notes.value.find((o) => o.title.toLowerCase().indexOf(q) > -1);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
return {
|
||||
qry,
|
||||
type: CardType.Note,
|
||||
data,
|
||||
} as CardItem;
|
||||
} else if (type !== undefined && type === CardType.Note) {
|
||||
const data = this.getState().notes.value.find((o) => o.id === qry);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user