Skip to content

Commit

Permalink
fix(lb-components): Add subAttribute handling in combine and segment
Browse files Browse the repository at this point in the history
  • Loading branch information
lihqi committed May 17, 2024
1 parent 41d9ec1 commit 358b71f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const useAudioCombine = (props: IProps) => {
setSelectedRegion,
} = props;
const { audioClipState, setAudioClipState } = useAudioClipStore();
const { selectedRegion, clipConfigurable, combined, clipTextList } = audioClipState;
const { selectedRegion, clipConfigurable, combined, clipTextList } =
audioClipState;
const { id } = selectedRegion;

const combineTextByConfig = (
Expand Down Expand Up @@ -101,7 +102,7 @@ ${targetText}`;
const start = Math.min(...times);
const end = Math.max(...times);

const region = {
const region: IAudioTimeSlice = {
id: waveRef.current?.util.getId('combined_'),
start,
end,
Expand All @@ -111,6 +112,7 @@ ${targetText}`;
? `${current.text}${target.text}`
: `${current.text}
${target.text}`,
subAttribute: target.subAttribute ?? {},
};
const newRegion = combineTextByConfig(region, current, target);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { useEffect, useRef } from 'react';
import { message as SenseMessage } from 'antd';
import { cKeyCode } from '@labelbee/lb-annotation';
import { TagUtils, cKeyCode } from '@labelbee/lb-annotation';
import { useAudioClipStore } from '@/components/audioAnnotate/audioContext';
import { useEventListener, useMemoizedFn } from 'ahooks';
import { ISetSelectedRegionParams } from '..';
Expand Down Expand Up @@ -36,7 +36,8 @@ const useAudioSegment = (props: IProps) => {
props;

const { audioClipState, setAudioClipState } = useAudioClipStore();
const { selectedRegion, clipConfigurable, segment, clipTextList } = audioClipState;
const { selectedRegion, clipConfigurable, segment, clipTextList, subAttributeList } =
audioClipState;
const { id } = selectedRegion;
const segmentTimeTip = useRef<null | number>(null);
const mouseEvent = useRef<null | MouseEvent>(null);
Expand Down Expand Up @@ -67,12 +68,14 @@ const useAudioSegment = (props: IProps) => {
...newData,
id: waveRef.current?.util.getId('segment_'),
end: time,
subAttribute: current.subAttribute ?? {},
};
const clearText = DataTransform.getClipTextByConfig(current, clipTextList, true);
const targetRight = {
...clearText,
id: waveRef.current?.util.getId('segment_'),
start: time,
subAttribute: TagUtils.getDefaultResultByConfig(subAttributeList ?? []),
};

updateRegion?.(targetLeft);
Expand Down

0 comments on commit 358b71f

Please sign in to comment.