mirror of
https://gitlab.com/walljm/dynamicbible.git
synced 2025-07-23 23:39: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[]>) {
|
async updateCards(queries: IStorable<readonly DataReference[]>) {
|
||||||
const cards: CardItem[] = [];
|
const cards: CardItem[] = [];
|
||||||
for (const q of queries.value) {
|
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);
|
cards.push(card);
|
||||||
}
|
}
|
||||||
this.dispatch(
|
this.dispatch(
|
||||||
@ -170,9 +170,19 @@ export class AppService extends createStateService(reducer, initialState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getCardByQuery(qry: string, type?: CardType): Promise<CardItem> {
|
private async getCardByQuery(qry: string, type?: CardType): Promise<CardItem> {
|
||||||
if (qry.startsWith('note:') || (type !== undefined && type === CardType.Note)) {
|
if (qry.startsWith('note:')) {
|
||||||
const id = qry.replace('note:', '');
|
const q = qry.toLocaleLowerCase().trim().replace('note:', '');
|
||||||
const data = this.getState().notes.value.find((o) => o.id === id);
|
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) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user