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>
This commit is contained in:
0xsysr3ll
2025-08-19 19:00:09 +02:00
committed by GitHub
parent 66d4cd63bb
commit 5c1583cf56

View File

@@ -378,7 +378,7 @@ const UserProfile = () => {
{user.userType === UserType.PLEX && {user.userType === UserType.PLEX &&
(user.id === currentUser?.id || (user.id === currentUser?.id ||
currentHasPermission(Permission.ADMIN)) && currentHasPermission(Permission.ADMIN)) &&
(!watchData || !!watchData.recentlyWatched.length) && (!watchData || !!watchData.recentlyWatched?.length) &&
!watchDataError && ( !watchDataError && (
<> <>
<div className="slider-header"> <div className="slider-header">
@@ -389,7 +389,7 @@ const UserProfile = () => {
<Slider <Slider
sliderKey="media" sliderKey="media"
isLoading={!watchData} isLoading={!watchData}
items={watchData?.recentlyWatched.map((item) => ( items={watchData?.recentlyWatched?.map((item) => (
<TmdbTitleCard <TmdbTitleCard
key={`media-slider-item-${item.id}`} key={`media-slider-item-${item.id}`}
id={item.id} id={item.id}