Merge branch 'bug-fixes-4' into 'main'

Bug fixes 4

See merge request walljm/dynamicbible!26
This commit is contained in:
Jason Wall 2024-03-01 21:43:55 +00:00
commit e2a91055cb
6 changed files with 28 additions and 24 deletions

View File

@ -22,11 +22,7 @@ export class NoteCardComponent extends CardComponent {
return this.cardItem.data as NoteItem;
}
constructor(
protected elementRef: ElementRef,
protected appService: AppService,
public dialog: MatDialog
) {
constructor(protected elementRef: ElementRef, protected appService: AppService, public dialog: MatDialog) {
super(elementRef, dialog, appService);
this.icon$ = appService.select((state) => state.settings.value.cardIcons.note);
@ -38,8 +34,12 @@ export class NoteCardComponent extends CardComponent {
this.copyToClip(text, html);
}
private xrefs: BibleReference[];
prepXref(xref: string) {
return xref.split(';').map((o) => new BibleReference(o));
if (this.xrefs === undefined) {
this.xrefs = xref.split(';').map((o) => new BibleReference(o));
}
return this.xrefs;
}
openPassage(ref: BibleReference) {

View File

@ -12,6 +12,7 @@
type="search"
autocomplete="off"
matInput
#contentView
#autoCompleteInput
[formControl]="searchControl"
[matAutocomplete]="auto"

View File

@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild, ChangeDetectionStrategy } from '@angular/core';
import { Component, OnInit, ViewChild, ChangeDetectionStrategy, ElementRef } from '@angular/core';
import { ActivatedRoute, Router, NavigationEnd } from '@angular/router';
import { UntypedFormControl } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
@ -27,9 +27,13 @@ export class SearchPageComponent extends SubscriberBase implements OnInit {
@ViewChild(MatAutocomplete)
autoComplete: MatAutocomplete;
@ViewChild('autoCompleteInput', { read: MatAutocompleteTrigger })
autoCompleteTrigger: MatAutocompleteTrigger;
@ViewChild('contentView')
contentView: ElementRef;
constructor(
private activatedRoute: ActivatedRoute,
private appService: AppService,
@ -84,6 +88,7 @@ export class SearchPageComponent extends SubscriberBase implements OnInit {
onSavedPagedLoaded(id: string) {
if (this.savedPagedLoaded) {
this.appService.getSavedPage(id);
this.contentView?.nativeElement?.focus();
return; // you did it! stop trying.
}
// the saved page hasn't loaded yet, wait then try again.

View File

@ -156,7 +156,8 @@ export class AppService extends createStateService(reducer, initialState) {
async updateCards(queries: IStorable<readonly DataReference[]>) {
const cards: CardItem[] = [];
for (const q of queries.value) {
const values = queries.value ?? [];
for (const q of values) {
const card = await this.getCardByQuery(q.qry.trim(), q.type);
cards.push(card);
}

View File

@ -122,7 +122,7 @@ export class StorageService extends SubscriberBase {
this.savedPagesRemoteObject
.valueChanges() // when the value changes
.subscribe((remoteData) => {
if (!isNullOrUndefined(remoteData) && !isNullOrUndefined(remoteData.value)) {
if (!isNullOrUndefined(remoteData)) {
// update the app state with remote data if it isn't null
// console.log('Data recieved from remote store', remoteData);
this.appService.updateSavedPages(remoteData);
@ -135,7 +135,7 @@ export class StorageService extends SubscriberBase {
this.noteItemsRemoteObject
.valueChanges() // when the value changes
.subscribe((remoteData) => {
if (!isNullOrUndefined(remoteData) && !isNullOrUndefined(remoteData.value)) {
if (!isNullOrUndefined(remoteData)) {
// update the app state with remote data if it isn't null
// console.log('Data recieved from remote store', remoteData);
this.appService.updateNotes(remoteData);
@ -150,7 +150,11 @@ export class StorageService extends SubscriberBase {
this.cardsRemoteObject
.valueChanges() // when the value changes
.subscribe((remoteData) => {
if (!isNullOrUndefined(remoteData) && !isNullOrUndefined(remoteData.value) && this.syncCurrentItems) {
if (!this.syncCurrentItems) {
return;
}
if (!isNullOrUndefined(remoteData)) {
// update the app state with remote data, but only if syncing is turned on.
this.appService.updateCards(remoteData);
}
@ -285,15 +289,15 @@ export class StorageService extends SubscriberBase {
}
// update local
this.local.set(this.cardsPath, v.currentCards).subscribe(
() => {
this.local.set(this.cardsPath, v.currentCards).subscribe({
next: () => {
// nop
},
// error
() => {
error: () => {
this.appService.dispatchError(`Something went wrong and the current cards weren't saved. :(`);
}
);
},
});
// since you updated the local variable above, this remote update will
// get picked up by the remote subscription below.

View File

@ -5,14 +5,7 @@
<title>Dynamic Bible</title>
<meta
name="viewport"
content="
width=device-width,
height=device-height,
initial-scale=1.0,
minimum-scale=1.0,
maximum-scale=1.0,
user-scalable=no
"
content="width=device-width,height=device-height,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"
/>
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />