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/state/lightbox.tsx | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/state/lightbox.tsx') diff --git a/src/state/lightbox.tsx b/src/state/lightbox.tsx index e3bddaee0..a97164327 100644 --- a/src/state/lightbox.tsx +++ b/src/state/lightbox.tsx @@ -1,29 +1,26 @@ import React from 'react' import {AppBskyActorDefs} from '@atproto/api' -import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' -interface Lightbox { - name: string -} +import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' -export class ProfileImageLightbox implements Lightbox { - name = 'profile-image' - constructor(public profile: AppBskyActorDefs.ProfileViewDetailed) {} +type ProfileImageLightbox = { + type: 'profile-image' + profile: AppBskyActorDefs.ProfileViewDetailed } -interface ImagesLightboxItem { +type ImagesLightboxItem = { uri: string alt?: string } -export class ImagesLightbox implements Lightbox { - name = 'images' - constructor(public images: ImagesLightboxItem[], public index: number) {} - setIndex(index: number) { - this.index = index - } +type ImagesLightbox = { + type: 'images' + images: ImagesLightboxItem[] + index: number } +type Lightbox = ProfileImageLightbox | ImagesLightbox + const LightboxContext = React.createContext<{ activeLightbox: Lightbox | null }>({ -- cgit 1.4.1