Skip to content

Commit

Permalink
Update some more checks to handle that the card might be null.
Browse files Browse the repository at this point in the history
noUncheckedIndexedAccess

Part of #711.
  • Loading branch information
jkomoros committed Feb 17, 2025
1 parent 82b64b6 commit 93424e7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/card-badges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ export const cardBadgesStyles = css`
//need to embed cardBadgeStyles at least once If selectTarget is passed, then it
//will render a checkbox that will have that method called with the ven ton
//change. If not provided, it will not render a select checkbox.
export const cardBadges = (light : boolean, card : OptionalFieldsCard, badgeMap : BadgeMap, selectTarget? : (e : MouseEvent) => void) => {
export const cardBadges = (light : boolean, card : OptionalFieldsCard | null, badgeMap : BadgeMap, selectTarget? : (e : MouseEvent) => void) => {
if (!badgeMap) badgeMap = {
stars: {},
reads: {},
todos: {},
readingList: {},
selected: {}
};
if (!card) return html``;
const starMap = badgeMap.stars || {};
const readMap = badgeMap.reads || {};
const todoMap = badgeMap.todos || {};
Expand Down
2 changes: 1 addition & 1 deletion src/components/card-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
class CardPreview extends LitElement {

@property({ type : Object })
card: Card | ProcessedCard;
card: Card | ProcessedCard | null;

@property({ type : Object })
badgeMap: BadgeMap;
Expand Down
2 changes: 1 addition & 1 deletion src/components/main-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class MainView extends connect(store)(PageViewElement) {
_keyboardNavigates: boolean;

@state()
_activePreviewCard: Card;
_activePreviewCard: Card | null;

@state()
_previewCardX : number;
Expand Down

0 comments on commit 93424e7

Please sign in to comment.