From 339f45ccbb043b9b2f46a459af4dfb368dfb705d Mon Sep 17 00:00:00 2001 From: dan 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.web.tsx | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/view/com/lightbox/Lightbox.web.tsx') diff --git a/src/view/com/lightbox/Lightbox.web.tsx b/src/view/com/lightbox/Lightbox.web.tsx index 942c9a686..9a0fa5d33 100644 --- a/src/view/com/lightbox/Lightbox.web.tsx +++ b/src/view/com/lightbox/Lightbox.web.tsx @@ -2,30 +2,26 @@ import React, {useCallback, useEffect, useState} from 'react' import { Image, ImageStyle, + Pressable, + StyleSheet, TouchableOpacity, TouchableWithoutFeedback, - StyleSheet, View, - Pressable, ViewStyle, } from 'react-native' import { FontAwesomeIcon, FontAwesomeIconStyle, } from '@fortawesome/react-native-fontawesome' -import {colors, s} from 'lib/styles' -import ImageDefaultHeader from './ImageViewing/components/ImageDefaultHeader' -import {Text} from '../util/text/Text' -import {useLingui} from '@lingui/react' import {msg} from '@lingui/macro' -import { - useLightbox, - useLightboxControls, - ImagesLightbox, - ProfileImageLightbox, -} from '#/state/lightbox' +import {useLingui} from '@lingui/react' + import {useWebBodyScrollLock} from '#/lib/hooks/useWebBodyScrollLock' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' +import {colors, s} from '#/lib/styles' +import {useLightbox, useLightboxControls} from '#/state/lightbox' +import {Text} from '../util/text/Text' +import ImageDefaultHeader from './ImageViewing/components/ImageDefaultHeader' interface Img { uri: string @@ -43,15 +39,15 @@ export function Lightbox() { } const initialIndex = - activeLightbox instanceof ImagesLightbox ? activeLightbox.index : 0 + activeLightbox.type === 'images' ? activeLightbox.index : 0 let imgs: Img[] | undefined - if (activeLightbox instanceof ProfileImageLightbox) { + if (activeLightbox.type === 'profile-image') { const opts = activeLightbox if (opts.profile.avatar) { imgs = [{uri: opts.profile.avatar}] } - } else if (activeLightbox instanceof ImagesLightbox) { + } else if (activeLightbox.type === 'images') { const opts = activeLightbox imgs = opts.images } -- cgit 1.4.1