Skip to content

Commit

Permalink
fix: do not display recipe details contents until loaded (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianpoy authored Nov 19, 2023
2 parents ec7d958 + c0e1282 commit 52af0ef
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
<ion-back-button [defaultHref]="defaultBackHref"></ion-back-button>
</ion-buttons>

<ion-title
>{{ 'pages.recipeDetails.pageTitle' | translate }}: {{ recipe.title
}}</ion-title
>
<ion-title> {{ 'pages.recipeDetails.pageTitle' | translate }} </ion-title>

<ion-buttons slot="end">
<ion-button (click)="presentPopover($event)">
Expand All @@ -21,7 +18,7 @@
<ion-refresher slot="fixed" (ionRefresh)="refresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
<ion-card class="ion-no-margin">
<ion-card *ngIf="recipe" class="ion-no-margin">
<ion-item lines="none">
<ion-thumbnail
class="ion-margin-top"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ion-thumbnail {
}

h2.recipeTitle {
font-size: 1.125rem;
margin-top: 0 !important;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class RecipePage {
release: () => void;
} = null;

recipe: Recipe;
recipe: Recipe | null;
similarRecipes: RecipeSummary[] = [];
recipeId: string;
ingredients?: ParsedIngredient[];
Expand Down Expand Up @@ -100,7 +100,7 @@ export class RecipePage {
throw new Error("No recipeId was provided");
}
this.recipeId = recipeId;
this.recipe = {} as Recipe;
this.recipe = null;

this.scale =
this.recipeCompletionTrackerService.getRecipeScale(this.recipeId) || 1;
Expand All @@ -115,7 +115,7 @@ export class RecipePage {
ionViewWillEnter() {
const loading = this.loadingService.start();

this.recipe = {} as Recipe;
this.recipe = null;

this.loadAll().then(
() => {
Expand Down Expand Up @@ -212,6 +212,8 @@ export class RecipePage {
}

updateRatingVisual() {
if (!this.recipe) return;

this.ratingVisual = new Array<string>(5)
.fill("star", 0, this.recipe.rating)
.fill("star-outline", this.recipe.rating, 5);
Expand Down Expand Up @@ -322,6 +324,8 @@ export class RecipePage {
}

applyScale() {
if (!this.recipe) return;

this.ingredients = this.recipeService.parseIngredients(
this.recipe.ingredients,
this.scale,
Expand Down Expand Up @@ -367,6 +371,8 @@ export class RecipePage {
}

private async _deleteRecipe() {
if (!this.recipe) return;

const loading = this.loadingService.start();

const response = await this.recipeService.delete(this.recipe.id);
Expand Down Expand Up @@ -423,6 +429,8 @@ export class RecipePage {
}

async moveToFolder(folderName: RecipeFolderName) {
if (!this.recipe) return;

const loading = this.loadingService.start();

this.recipe.folder = folderName;
Expand Down Expand Up @@ -462,6 +470,8 @@ export class RecipePage {
}

async addLabel(title: string) {
if (!this.recipe) return;

if (title.length === 0) {
const message = await this.translate
.get("pages.recipeDetails.enterLabelWarning")
Expand Down Expand Up @@ -521,6 +531,8 @@ export class RecipePage {
}

private async _deleteLabel(label: Label) {
if (!this.recipe) return;

const loading = this.loadingService.start();

await this.labelService.removeFromRecipe({
Expand All @@ -532,6 +544,8 @@ export class RecipePage {
}

async cloneRecipe() {
if (!this.recipe) return;

const loading = this.loadingService.start();
const response = await this.recipeService.create({
...this.recipe,
Expand Down Expand Up @@ -587,6 +601,8 @@ export class RecipePage {
}

async openImageViewer() {
if (!this.recipe) return;

const imageViewerModal = await this.modalCtrl.create({
component: ImageViewerComponent,
componentProps: {
Expand All @@ -597,6 +613,8 @@ export class RecipePage {
}

pinRecipe() {
if (!this.recipe) return;

this.cookingToolbarService.pinRecipe({
id: this.recipe.id,
title: this.recipe.title,
Expand All @@ -605,6 +623,8 @@ export class RecipePage {
}

unpinRecipe() {
if (!this.recipe) return;

this.cookingToolbarService.unpinRecipe(this.recipe.id);
}

Expand Down

0 comments on commit 52af0ef

Please sign in to comment.