diff --git a/src/components/MediaPreview.tsx b/src/components/MediaPreview.tsx index 7b0e38e0b..e6697df6c 100644 --- a/src/components/MediaPreview.tsx +++ b/src/components/MediaPreview.tsx @@ -57,7 +57,7 @@ export function Embed({ // of filter().slice().map() so we stop at 4 viewable items rather than // walking every item in a 10-image gallery. const tiles: React.ReactNode[] = [] - for (const item of e.view.items) { + for (const item of Array.isArray(e.view.items) ? e.view.items : []) { if (tiles.length >= 4) break if (!AppBskyEmbedGallery.isViewImage(item)) continue if (peekable) { diff --git a/src/components/Post/Embed/ImageEmbed.tsx b/src/components/Post/Embed/ImageEmbed.tsx index 9d4730206..1118b90e8 100644 --- a/src/components/Post/Embed/ImageEmbed.tsx +++ b/src/components/Post/Embed/ImageEmbed.tsx @@ -31,13 +31,17 @@ export function ImageEmbed({ const {openLightbox} = useLightboxControls() const images: AppBskyEmbedImages.ViewImage[] = embed.type === 'gallery' - ? embed.view.items.filter(AppBskyEmbedGallery.isViewImage).map(item => ({ - thumb: item.thumbnail, - fullsize: item.fullsize, - alt: item.alt, - aspectRatio: item.aspectRatio, - })) - : embed.view.images + ? (Array.isArray(embed.view.items) ? embed.view.items : []) + .filter(AppBskyEmbedGallery.isViewImage) + .map(item => ({ + thumb: item.thumbnail, + fullsize: item.fullsize, + alt: item.alt, + aspectRatio: item.aspectRatio, + })) + : Array.isArray(embed.view.images) + ? embed.view.images + : [] const useExpandedLayout = embed.type === 'gallery' ? images.length > MAX_GRID_IMAGES diff --git a/src/lib/strings/embed-player.ts b/src/lib/strings/embed-player.ts index 40abc13fa..6614836f9 100644 --- a/src/lib/strings/embed-player.ts +++ b/src/lib/strings/embed-player.ts @@ -6,8 +6,8 @@ const {height: SCREEN_HEIGHT} = Dimensions.get('window') const IFRAME_HOST = IS_WEB ? // @ts-ignore only for web - window.location.host === 'localhost:8100' - ? 'http://localhost:8100' + typeof window !== 'undefined' + ? window.location.origin : 'https://blacksky.community' : __DEV__ && !process.env.JEST_WORKER_ID ? 'http://localhost:8100'