Skip to content

Revert "Use signals to more idiomatically propagate fetch results"#158

Merged
seiyria merged 1 commit intomasterfrom
revert-156-fixed-card-page
Dec 29, 2025
Merged

Revert "Use signals to more idiomatically propagate fetch results"#158
seiyria merged 1 commit intomasterfrom
revert-156-fixed-card-page

Conversation

@seiyria
Copy link
Member

@seiyria seiyria commented Dec 29, 2025

Reverts #156

Copilot AI review requested due to automatic review settings December 29, 2025 04:56
@seiyria seiyria merged commit 53ebb04 into master Dec 29, 2025
2 checks passed
@seiyria seiyria deleted the revert-156-fixed-card-page branch December 29, 2025 04:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts changes from PR #156 that introduced Angular signals for state management, returning to a more imperative approach with plain properties and explicit method calls for managing card and metadata.

  • Converts signal-based reactive state back to plain properties in MetaService and CardsService
  • Replaces computed signals with explicit initialization methods (loadExternals, setCards)
  • Changes CardPage from reactive signal-based data loading to imperative loadCardData method

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/app/meta.service.ts Reverts signals to plain properties, adds loadExternals() method to populate lookup dictionaries
src/app/cards.service.ts Reverts signals to plain properties, adds setCards() method, removes loaded property, converts reformatCardsWithErrataAndFAQ from computed signal to method
src/app/card/card.page.ts Replaces reactive computed cardData and template with imperative loadCardData method, adds effect for locale changes
src/app/card/card.page.html Updates template property access from function call to direct property access

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +92 to +100
untracked(() => {
this.loadCardData(this.route.snapshot.paramMap.get('id') ?? '');
});
});
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This effect will trigger on every change to currentLocale(), but it doesn't actually use the cardData signal value correctly (see the bug on line 93). Additionally, the effect reloads card data whenever the locale changes, but the untracked callback makes this logic confusing. Consider restructuring this to be more clear about when card data should be reloaded.

Copilot uses AI. Check for mistakes.

public getProductNameByProductId(productId: string): string {
return this.productNamesByProductId()[productId] ?? "";
return this.productNamesByProductId[productId];
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should return a default value when productId is not found in the dictionary, similar to the signal-based implementation that returned an empty string. The current implementation will return undefined when the key doesn't exist, which could cause issues for consumers expecting a string.

Suggested change
return this.productNamesByProductId[productId];
return this.productNamesByProductId[productId] ?? '';

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +78
return this.templatesByProductId[productId][
this.localeService.currentLocale()
];
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method can throw an error if productId is not found in templatesByProductId or if the product doesn't have a template for the current locale. The signal-based implementation had a fallback to an empty string. Add null-safe access and a fallback value to prevent runtime errors.

Suggested change
return this.templatesByProductId[productId][
this.localeService.currentLocale()
];
const locale = this.localeService.currentLocale();
return this.templatesByProductId[productId]?.[locale] ?? '';

Copilot uses AI. Check for mistakes.

public getRulesByProductId(productId: string): string {
return this.rulesByProductId()[productId] ?? '';
return this.rulesByProductId[productId];
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should return a default value when productId is not found in the dictionary, similar to the signal-based implementation that returned an empty string. The current implementation will return undefined when the key doesn't exist, which could cause issues for consumers expecting a string.

Suggested change
return this.rulesByProductId[productId];
return this.rulesByProductId[productId] ?? '';

Copilot uses AI. Check for mistakes.
Comment on lines +93 to 94
if (!this.cardData) return;

Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks if this.cardData is truthy, but cardData is a WritableSignal. This check will always be truthy since the signal object itself always exists. The condition should be this.cardData() to check the signal's value.

Suggested change
if (!this.cardData) return;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants