Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f61a8f3045 | ||
|
|
4a4baddb34 |
@@ -0,0 +1,40 @@
|
|||||||
|
name: Workflow for Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'release/v*'
|
||||||
|
- 'hotfix/v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync-release-branch:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup Git
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions"
|
||||||
|
git config user.email "actions@github.com"
|
||||||
|
|
||||||
|
- name: Fetch all history
|
||||||
|
run: git fetch --unshallow || git fetch --all
|
||||||
|
|
||||||
|
- name: Determine Tag Type
|
||||||
|
id: tagtype
|
||||||
|
run: |
|
||||||
|
if [[ ${{ github.ref }} == refs/tags/release/v* ]]; then
|
||||||
|
echo "::set-output name=type::release"
|
||||||
|
elif [[ ${{ github.ref }} == refs/tags/hotfix/v* ]]; then
|
||||||
|
echo "::set-output name=type::hotfix"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check out the release branch
|
||||||
|
run: |
|
||||||
|
git checkout release || git checkout -b release
|
||||||
|
|
||||||
|
- name: Sync release branch to tag
|
||||||
|
run: |
|
||||||
|
git reset --hard ${{ github.ref }}
|
||||||
|
git push -f origin release
|
||||||
@@ -9,16 +9,14 @@ import type { ChartLine, TvWidget } from '@/constants/tvchart';
|
|||||||
|
|
||||||
import { useStringGetter } from '@/hooks';
|
import { useStringGetter } from '@/hooks';
|
||||||
|
|
||||||
import {
|
import { getCurrentMarketOrders, getCurrentMarketPositionData } from '@/state/accountSelectors';
|
||||||
getCurrentMarketOrders,
|
|
||||||
getCurrentMarketPositionData,
|
|
||||||
getIsAccountConnected,
|
|
||||||
} from '@/state/accountSelectors';
|
|
||||||
import { getAppTheme, getAppColorMode } from '@/state/configsSelectors';
|
import { getAppTheme, getAppColorMode } from '@/state/configsSelectors';
|
||||||
|
|
||||||
import { MustBigNumber } from '@/lib/numbers';
|
import { MustBigNumber } from '@/lib/numbers';
|
||||||
import { getChartLineColors } from '@/lib/tradingView/utils';
|
import { getChartLineColors } from '@/lib/tradingView/utils';
|
||||||
|
|
||||||
|
let chartLines: Record<string, ChartLine> = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Hook to handle drawing chart lines
|
* @description Hook to handle drawing chart lines
|
||||||
*/
|
*/
|
||||||
@@ -27,47 +25,43 @@ export const useChartLines = ({
|
|||||||
tvWidget,
|
tvWidget,
|
||||||
displayButton,
|
displayButton,
|
||||||
isChartReady,
|
isChartReady,
|
||||||
chartLinesRef,
|
|
||||||
}: {
|
}: {
|
||||||
tvWidget: TvWidget | null;
|
tvWidget: TvWidget | null;
|
||||||
displayButton: HTMLElement | null;
|
displayButton: HTMLElement | null;
|
||||||
isChartReady: boolean;
|
isChartReady?: boolean;
|
||||||
chartLinesRef: React.MutableRefObject<Record<string, ChartLine>>;
|
|
||||||
}) => {
|
}) => {
|
||||||
const [showOrderLines, setShowOrderLines] = useState(true);
|
const [showOrderLines, setShowOrderLines] = useState(false);
|
||||||
|
|
||||||
const stringGetter = useStringGetter();
|
const stringGetter = useStringGetter();
|
||||||
|
|
||||||
const appTheme = useSelector(getAppTheme);
|
const appTheme = useSelector(getAppTheme);
|
||||||
const appColorMode = useSelector(getAppColorMode);
|
const appColorMode = useSelector(getAppColorMode);
|
||||||
|
|
||||||
const isAccountConnected = useSelector(getIsAccountConnected);
|
|
||||||
|
|
||||||
const currentMarketPositionData = useSelector(getCurrentMarketPositionData, shallowEqual);
|
const currentMarketPositionData = useSelector(getCurrentMarketPositionData, shallowEqual);
|
||||||
const currentMarketOrders: SubaccountOrder[] = useSelector(getCurrentMarketOrders, shallowEqual);
|
const currentMarketOrders: SubaccountOrder[] = useSelector(getCurrentMarketOrders, shallowEqual);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isChartReady && displayButton) {
|
if (isChartReady && displayButton) {
|
||||||
displayButton.onclick = () => setShowOrderLines(!showOrderLines);
|
displayButton.onclick = () => {
|
||||||
|
const newShowOrderLinesState = !showOrderLines;
|
||||||
|
if (newShowOrderLinesState) {
|
||||||
|
displayButton?.classList?.add('order-lines-active');
|
||||||
|
} else {
|
||||||
|
displayButton?.classList?.remove('order-lines-active');
|
||||||
|
}
|
||||||
|
setShowOrderLines(newShowOrderLinesState);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}, [isChartReady, showOrderLines]);
|
}, [isChartReady, showOrderLines]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isAccountConnected) {
|
if (tvWidget && isChartReady) {
|
||||||
deleteChartLines();
|
|
||||||
}
|
|
||||||
}, [isAccountConnected]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (isChartReady && tvWidget) {
|
|
||||||
tvWidget.onChartReady(() => {
|
tvWidget.onChartReady(() => {
|
||||||
tvWidget.chart().dataReady(() => {
|
tvWidget.chart().dataReady(() => {
|
||||||
if (showOrderLines) {
|
if (showOrderLines) {
|
||||||
displayButton?.classList?.add('order-lines-active');
|
|
||||||
drawOrderLines();
|
drawOrderLines();
|
||||||
drawPositionLine();
|
drawPositionLine();
|
||||||
} else {
|
} else {
|
||||||
displayButton?.classList?.remove('order-lines-active');
|
|
||||||
deleteChartLines();
|
deleteChartLines();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -84,13 +78,13 @@ export const useChartLines = ({
|
|||||||
const key = currentMarketPositionData.id;
|
const key = currentMarketPositionData.id;
|
||||||
const price = MustBigNumber(entryPrice).toNumber();
|
const price = MustBigNumber(entryPrice).toNumber();
|
||||||
|
|
||||||
const maybePositionLine = chartLinesRef.current[key]?.line;
|
const maybePositionLine = chartLines[key]?.line;
|
||||||
const shouldShow = size && size !== 0;
|
const shouldShow = size && size !== 0;
|
||||||
|
|
||||||
if (!shouldShow) {
|
if (!shouldShow) {
|
||||||
if (maybePositionLine) {
|
if (maybePositionLine) {
|
||||||
maybePositionLine.remove();
|
maybePositionLine.remove();
|
||||||
delete chartLinesRef.current[key];
|
delete chartLines[key];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -112,9 +106,9 @@ export const useChartLines = ({
|
|||||||
.setQuantity(quantity);
|
.setQuantity(quantity);
|
||||||
|
|
||||||
if (positionLine) {
|
if (positionLine) {
|
||||||
const chartLine: ChartLine = { line: positionLine, chartLineType: 'position' };
|
const chartLine = { line: positionLine, chartLineType: 'position' };
|
||||||
setLineColors({ chartLine: chartLine });
|
setLineColors({ chartLine: chartLine });
|
||||||
chartLinesRef.current[key] = chartLine;
|
chartLines[key] = chartLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,12 +143,12 @@ export const useChartLines = ({
|
|||||||
!cancelReason &&
|
!cancelReason &&
|
||||||
(status === AbacusOrderStatus.open || status === AbacusOrderStatus.untriggered);
|
(status === AbacusOrderStatus.open || status === AbacusOrderStatus.untriggered);
|
||||||
|
|
||||||
const maybeOrderLine = chartLinesRef.current[key]?.line;
|
const maybeOrderLine = chartLines[key]?.line;
|
||||||
|
|
||||||
if (!shouldShow) {
|
if (!shouldShow) {
|
||||||
if (maybeOrderLine) {
|
if (maybeOrderLine) {
|
||||||
maybeOrderLine.remove();
|
maybeOrderLine.remove();
|
||||||
delete chartLinesRef.current[key];
|
delete chartLines[key];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -176,7 +170,7 @@ export const useChartLines = ({
|
|||||||
chartLineType: ORDER_SIDES[side.name],
|
chartLineType: ORDER_SIDES[side.name],
|
||||||
};
|
};
|
||||||
setLineColors({ chartLine: chartLine });
|
setLineColors({ chartLine: chartLine });
|
||||||
chartLinesRef.current[key] = chartLine;
|
chartLines[key] = chartLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,10 +179,10 @@ export const useChartLines = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deleteChartLines = () => {
|
const deleteChartLines = () => {
|
||||||
Object.values(chartLinesRef.current).forEach(({ line }) => {
|
Object.values(chartLines).forEach(({ line }) => {
|
||||||
line.remove();
|
line.remove();
|
||||||
});
|
});
|
||||||
chartLinesRef.current = {};
|
chartLines = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
const setLineColors = ({ chartLine }: { chartLine: ChartLine }) => {
|
const setLineColors = ({ chartLine }: { chartLine: ChartLine }) => {
|
||||||
@@ -210,4 +204,6 @@ export const useChartLines = ({
|
|||||||
maybeQuantityColor &&
|
maybeQuantityColor &&
|
||||||
line.setLineColor(maybeQuantityColor).setQuantityBackgroundColor(maybeQuantityColor);
|
line.setLineColor(maybeQuantityColor).setQuantityBackgroundColor(maybeQuantityColor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return { chartLines };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export const useChartMarketAndResolution = ({
|
|||||||
* @description Hook to handle changing markets - intentionally should avoid triggering on change of resolutions.
|
* @description Hook to handle changing markets - intentionally should avoid triggering on change of resolutions.
|
||||||
*/
|
*/
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isWidgetReady && currentMarketId !== tvWidget?.activeChart().symbol()) {
|
if (currentMarketId && isWidgetReady) {
|
||||||
const resolution = savedResolution || selectedResolution;
|
const resolution = savedResolution || selectedResolution;
|
||||||
tvWidget?.setSymbol(currentMarketId, resolution as ResolutionString, () => {});
|
tvWidget?.setSymbol(currentMarketId, resolution as ResolutionString, () => {});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import styled, { type AnyStyledComponent, css } from 'styled-components';
|
|||||||
|
|
||||||
import type { ResolutionString } from 'public/tradingview/charting_library';
|
import type { ResolutionString } from 'public/tradingview/charting_library';
|
||||||
|
|
||||||
import type { ChartLine, TvWidget } from '@/constants/tvchart';
|
import type { TvWidget } from '@/constants/tvchart';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useChartLines,
|
useChartLines,
|
||||||
@@ -27,16 +27,13 @@ export const TvChart = () => {
|
|||||||
const displayButtonRef = useRef<HTMLElement | null>(null);
|
const displayButtonRef = useRef<HTMLElement | null>(null);
|
||||||
const displayButton = displayButtonRef.current;
|
const displayButton = displayButtonRef.current;
|
||||||
|
|
||||||
const chartLinesRef = useRef<Record<string, ChartLine>>({});
|
|
||||||
const chartLines = chartLinesRef.current;
|
|
||||||
|
|
||||||
const { savedResolution } = useTradingView({ tvWidgetRef, displayButtonRef, setIsChartReady });
|
const { savedResolution } = useTradingView({ tvWidgetRef, displayButtonRef, setIsChartReady });
|
||||||
useChartMarketAndResolution({
|
useChartMarketAndResolution({
|
||||||
tvWidget,
|
tvWidget,
|
||||||
isWidgetReady,
|
isWidgetReady,
|
||||||
savedResolution: savedResolution as ResolutionString | undefined,
|
savedResolution: savedResolution as ResolutionString | undefined,
|
||||||
});
|
});
|
||||||
useChartLines({ tvWidget, displayButton, isChartReady, chartLinesRef });
|
const { chartLines } = useChartLines({ tvWidget, displayButton, isChartReady });
|
||||||
useTradingViewTheme({ tvWidget, isWidgetReady, chartLines });
|
useTradingViewTheme({ tvWidget, isWidgetReady, chartLines });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user