From 339f45ccbb043b9b2f46a459af4dfb368dfb705d Mon Sep 17 00:00:00 2001
From: dan <dan.abramov@gmail.com>
Date: Tue, 29 Oct 2024 20:58:38 +0000
Subject: Refactor lightbox model to plain object (#5999)

* Refactor lightbox model to plain object

* Rename name to type
---
 src/view/com/lightbox/Lightbox.tsx | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

(limited to 'src/view/com/lightbox/Lightbox.tsx')

diff --git a/src/view/com/lightbox/Lightbox.tsx b/src/view/com/lightbox/Lightbox.tsx
index e1c12e419..b6bc670c1 100644
--- a/src/view/com/lightbox/Lightbox.tsx
+++ b/src/view/com/lightbox/Lightbox.tsx
@@ -9,12 +9,7 @@ import {useLingui} from '@lingui/react'
 import {saveImageToMediaLibrary, shareImageModal} from '#/lib/media/manip'
 import {colors, s} from '#/lib/styles'
 import {isIOS} from '#/platform/detection'
-import {
-  ImagesLightbox,
-  ProfileImageLightbox,
-  useLightbox,
-  useLightboxControls,
-} from '#/state/lightbox'
+import {useLightbox, useLightboxControls} from '#/state/lightbox'
 import {ScrollView} from '#/view/com/util/Views'
 import {Button} from '../util/forms/Button'
 import {Text} from '../util/text/Text'
@@ -32,8 +27,8 @@ export function Lightbox() {
 
   if (!activeLightbox) {
     return null
-  } else if (activeLightbox.name === 'profile-image') {
-    const opts = activeLightbox as ProfileImageLightbox
+  } else if (activeLightbox.type === 'profile-image') {
+    const opts = activeLightbox
     return (
       <ImageView
         images={[{uri: opts.profile.avatar || ''}]}
@@ -43,8 +38,8 @@ export function Lightbox() {
         FooterComponent={LightboxFooter}
       />
     )
-  } else if (activeLightbox.name === 'images') {
-    const opts = activeLightbox as ImagesLightbox
+  } else if (activeLightbox.type === 'images') {
+    const opts = activeLightbox
     return (
       <ImageView
         images={opts.images.map(img => ({...img}))}
@@ -107,12 +102,12 @@ function LightboxFooter({imageIndex}: {imageIndex: number}) {
 
   let altText = ''
   let uri = ''
-  if (lightbox.name === 'images') {
-    const opts = lightbox as ImagesLightbox
+  if (lightbox.type === 'images') {
+    const opts = lightbox
     uri = opts.images[imageIndex].uri
     altText = opts.images[imageIndex].alt || ''
-  } else if (lightbox.name === 'profile-image') {
-    const opts = lightbox as ProfileImageLightbox
+  } else if (lightbox.type === 'profile-image') {
+    const opts = lightbox
     uri = opts.profile.avatar || ''
   }
 
-- 
cgit 1.4.1

