Refactor lightbox model to plain object (#5999)
* Refactor lightbox model to plain object * Rename name to type
This commit is contained in:
+11
-14
@@ -1,29 +1,26 @@
|
||||
import React from 'react'
|
||||
import {AppBskyActorDefs} from '@atproto/api'
|
||||
|
||||
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
||||
|
||||
interface Lightbox {
|
||||
name: string
|
||||
type ProfileImageLightbox = {
|
||||
type: 'profile-image'
|
||||
profile: AppBskyActorDefs.ProfileViewDetailed
|
||||
}
|
||||
|
||||
export class ProfileImageLightbox implements Lightbox {
|
||||
name = 'profile-image'
|
||||
constructor(public 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
|
||||
}>({
|
||||
|
||||
Reference in New Issue
Block a user