diff options
author | dan <dan.abramov@gmail.com> | 2024-10-29 20:58:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-29 20:58:38 +0000 |
commit | 339f45ccbb043b9b2f46a459af4dfb368dfb705d (patch) | |
tree | c023f21805427d5fb01366fa077f4cf7a73d5a8e /src/state/lightbox.tsx | |
parent | 1cfcffd79eb8298e628c9bb9b71570e1b1269c6a (diff) | |
download | voidsky-339f45ccbb043b9b2f46a459af4dfb368dfb705d.tar.zst |
Refactor lightbox model to plain object (#5999)
* Refactor lightbox model to plain object * Rename name to type
Diffstat (limited to 'src/state/lightbox.tsx')
-rw-r--r-- | src/state/lightbox.tsx | 25 |
1 files changed, 11 insertions, 14 deletions
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 }>({ |