Skip to content

Commit 5c1583c

Browse files
authored
fix(UserProfile): handle optional chaining for recentlyWatched data (#1852)
This PR fixes a client-side TypeError in the "Recently Watched" section of user profiles. The issue occurred when recentlyWatched was undefined. The fix adds optional chaining (?.) to prevent the app from crashing. Signed-off-by: 0xsysr3ll <0xsysr3ll@pm.me>
1 parent 66d4cd6 commit 5c1583c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/components/UserProfile/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ const UserProfile = () => {
378378
{user.userType === UserType.PLEX &&
379379
(user.id === currentUser?.id ||
380380
currentHasPermission(Permission.ADMIN)) &&
381-
(!watchData || !!watchData.recentlyWatched.length) &&
381+
(!watchData || !!watchData.recentlyWatched?.length) &&
382382
!watchDataError && (
383383
<>
384384
<div className="slider-header">
@@ -389,7 +389,7 @@ const UserProfile = () => {
389389
<Slider
390390
sliderKey="media"
391391
isLoading={!watchData}
392-
items={watchData?.recentlyWatched.map((item) => (
392+
items={watchData?.recentlyWatched?.map((item) => (
393393
<TmdbTitleCard
394394
key={`media-slider-item-${item.id}`}
395395
id={item.id}

0 commit comments

Comments
 (0)