Skip to content

Commit

Permalink
[improve] variable renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
VecHK committed Jan 5, 2024
1 parent f77acd2 commit 2acaca8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions front/src/components/Gallery/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useEffect, useMemo, useState } from 'react'
import './index.scss'

import Title from 'components/Title'
import Waterfall, { WaterfallLayoutConfigure } from 'components/Waterfall'
import Waterfall, { WaterfallLayoutConfigure, Props as WaterfallLayoutProps } from 'components/Waterfall'
import { Gallery, Photo } from 'api/photo'
import { CoverClickEvent, Props as PhotoBoxProps } from 'components/PhotoBox'
import Submission from 'components/Submission'
Expand Down Expand Up @@ -135,13 +135,13 @@ export type Props = {
cannot_select_vote?: boolean
show_vote_button: boolean
gallery: Gallery
selectedIdList: number[]
selected_id_list: WaterfallLayoutProps['selected_id_list']
onClickVote?: (photo_id: Photo['id']) => void
onClickCover: (clickInfo: CoverClickEvent, photo_id: Photo['id']) => void
}
export default ({
cannot_select_vote = false,
show_vote_button, gallery, selectedIdList, onClickVote, onClickCover,
show_vote_button, gallery, selected_id_list, onClickVote, onClickCover,
}: Props) => {
const layout = useWaterfallLayout(gallery)

Expand All @@ -152,14 +152,14 @@ export default ({
layout_configure={layout}
cannot_select_vote={cannot_select_vote}
photos={gallery.photos}
selectedIdList={selectedIdList}
selected_id_list={selected_id_list}
show_vote_button={show_vote_button}
onClickCover={onClickCover}
onClickVote={(photoId) => {
onClickVote && onClickVote(photoId)
}}
/>
), [cannot_select_vote, gallery.photos, show_vote_button, layout, onClickCover, onClickVote, selectedIdList])
), [cannot_select_vote, gallery.photos, show_vote_button, layout, onClickCover, onClickVote, selected_id_list])

return (
<div className="gallery">
Expand Down
1 change: 0 additions & 1 deletion front/src/components/PhotoBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ export const PhotoBoxDimension = forwardRef< DimensionUnknown, Props>((props, re

const PhotoBox = forwardRef<HTMLDivElement, Props>((props, ref) => {
const { type, vertial_gutter, box_width, photo, hideMember, avatar, desc, style, vote_button_status } = props
const vote_button_is_highlight = vote_button_status === 'selected'

const [thumb_loaded, thumb] = useQueueload(photo.thumb)
const [avatar_loaded, avatarThumb] = useQueueload(avatar?.thumb)
Expand Down
6 changes: 3 additions & 3 deletions front/src/components/Waterfall/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type Props = {
onClickVote(photo_id: Photo['id']): void
onClickCover: WaterfallLayoutClickCoverHandler

selectedIdList: number[]
selected_id_list: number[]
}

function calcTotalBoxWidth({
Expand All @@ -62,7 +62,7 @@ export default (props: Props) => {
show_vote_button,
layout_configure,
photos,
selectedIdList
selected_id_list
} = props
const { box_type, vertial_gutter, gallery_width } = layout_configure
const [ box_width ] = calcTotalBoxWidth(layout_configure)
Expand Down Expand Up @@ -118,7 +118,7 @@ export default (props: Props) => {
show_vote_button: show_vote_button,
hideMember: !photo.member,
vote_button_status: (
(selectedIdList && (selectedIdList.indexOf(photo.id) !== -1)) ?
(selected_id_list && (selected_id_list.indexOf(photo.id) !== -1)) ?
'selected' :
(props.cannot_select_vote ? 'cannot-select' : 'un-selected')
),
Expand Down
6 changes: 3 additions & 3 deletions front/src/utils/queue-load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { findListByProperty, removeListItemByIdx } from './common'
import download from './download'
import useSafeState from 'hooks/useSafeState'

export const __MAX_PARALLEL_NUMBER__ = 3

type Load = {
blob: Blob;
blobUrl: string;
Expand Down Expand Up @@ -73,8 +75,6 @@ export function useQueueload(loadsrc: string | undefined, need_base64_url: boole
return [loaded, back_src] as const
}

export const MAX_PARALLEL_NUMBER = 3

type Src = string
type LoadTask = {
src: Src
Expand Down Expand Up @@ -107,7 +107,7 @@ export function QueueLoad() {
return
} else if (
isLoading() &&
( getConcurrentTasks().length >= MAX_PARALLEL_NUMBER )
( getConcurrentTasks().length >= __MAX_PARALLEL_NUMBER__ )
) {
return
} else {
Expand Down

0 comments on commit 2acaca8

Please sign in to comment.