fix: resolve TypeScript error by renaming conflicting lineHit variable
This commit is contained in:
parent
08bd9625ae
commit
025cf6d973
1 changed files with 7 additions and 7 deletions
|
|
@ -763,25 +763,25 @@ const CandleChart = forwardRef<CandleChartHandle, CandleChartProps>(
|
||||||
const timestamp = typeof time === 'string' ? Date.parse(time) / 1000 : (time as number);
|
const timestamp = typeof time === 'string' ? Date.parse(time) / 1000 : (time as number);
|
||||||
|
|
||||||
// First, check for line hit using primitives' hitTest
|
// First, check for line hit using primitives' hitTest
|
||||||
let lineHit: { id: number; primitive: TrendLine } | null = null;
|
let deleteLineHit: { id: number; primitive: TrendLine } | null = null;
|
||||||
linePrimitivesRef.current.forEach((primitive, id) => {
|
linePrimitivesRef.current.forEach((primitive, id) => {
|
||||||
const hit = primitive.hitTest(timeCoordinate, priceCoordinate);
|
const hit = primitive.hitTest(timeCoordinate, priceCoordinate);
|
||||||
if (hit) {
|
if (hit) {
|
||||||
lineHit = { id, primitive };
|
deleteLineHit = { id, primitive };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (lineHit) {
|
if (deleteLineHit) {
|
||||||
// Delete the clicked line
|
// Delete the clicked line
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/api/annotations/${lineHit.id}`, {
|
const response = await fetch(`/api/annotations/${deleteLineHit.id}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
seriesRef.current!.detachPrimitive(lineHit.primitive);
|
seriesRef.current!.detachPrimitive(deleteLineHit.primitive);
|
||||||
linePrimitivesRef.current.delete(lineHit.id);
|
linePrimitivesRef.current.delete(deleteLineHit.id);
|
||||||
if (selectedLineId === lineHit.id) {
|
if (selectedLineId === deleteLineHit.id) {
|
||||||
setSelectedLineId(null);
|
setSelectedLineId(null);
|
||||||
}
|
}
|
||||||
await fetchAnnotations();
|
await fetchAnnotations();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue