跳转评论

This commit is contained in:
IndieKKY
2024-09-19 15:08:15 +08:00
parent 1f1d48b56a
commit be6b94164d
16 changed files with 3174 additions and 2329 deletions

View File

@@ -1,13 +1,24 @@
import {useAppDispatch} from './redux'
import {useAppDispatch, useAppSelector} from './redux'
import React, {useCallback} from 'react'
import {setNeedScroll} from '../redux/envReducer'
import {setNeedScroll, setReviewAction, setTempData} from '../redux/envReducer'
const useSubtitle = () => {
const dispatch = useAppDispatch()
const reviewed = useAppSelector(state => state.env.tempData.reviewed)
const reviewAction = useAppSelector(state => state.env.reviewAction)
const reviewActions = useAppSelector(state => state.env.tempData.reviewActions)
const move = useCallback((time: number, togglePause: boolean) => {
window.parent.postMessage({type: 'move', time, togglePause}, '*')
}, [])
//review action
if (reviewed === undefined && !reviewAction) {
dispatch(setReviewAction(true))
dispatch(setTempData({
reviewActions: (reviewActions ?? 0) + 1
}))
}
}, [dispatch, reviewAction, reviewActions, reviewed])
const scrollIntoView = useCallback((ref: React.RefObject<HTMLDivElement>) => {
ref.current?.scrollIntoView({behavior: 'smooth', block: 'center'})