Compare commits

..
Author SHA1 Message Date
Bill He f61a8f3045 Update release to use tags for hotfix 2024-02-22 14:12:21 -08:00
Bill He 4a4baddb34 Github action for syncing the release branch 2024-02-21 11:17:00 -08:00
4 changed files with 69 additions and 36 deletions
+40
View File
@@ -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
+26 -30
View File
@@ -9,16 +9,14 @@ import type { ChartLine, TvWidget } from '@/constants/tvchart';
import { useStringGetter } from '@/hooks';
import {
getCurrentMarketOrders,
getCurrentMarketPositionData,
getIsAccountConnected,
} from '@/state/accountSelectors';
import { getCurrentMarketOrders, getCurrentMarketPositionData } from '@/state/accountSelectors';
import { getAppTheme, getAppColorMode } from '@/state/configsSelectors';
import { MustBigNumber } from '@/lib/numbers';
import { getChartLineColors } from '@/lib/tradingView/utils';
let chartLines: Record<string, ChartLine> = {};
/**
* @description Hook to handle drawing chart lines
*/
@@ -27,47 +25,43 @@ export const useChartLines = ({
tvWidget,
displayButton,
isChartReady,
chartLinesRef,
}: {
tvWidget: TvWidget | null;
displayButton: HTMLElement | null;
isChartReady: boolean;
chartLinesRef: React.MutableRefObject<Record<string, ChartLine>>;
isChartReady?: boolean;
}) => {
const [showOrderLines, setShowOrderLines] = useState(true);
const [showOrderLines, setShowOrderLines] = useState(false);
const stringGetter = useStringGetter();
const appTheme = useSelector(getAppTheme);
const appColorMode = useSelector(getAppColorMode);
const isAccountConnected = useSelector(getIsAccountConnected);
const currentMarketPositionData = useSelector(getCurrentMarketPositionData, shallowEqual);
const currentMarketOrders: SubaccountOrder[] = useSelector(getCurrentMarketOrders, shallowEqual);
useEffect(() => {
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]);
useEffect(() => {
if (!isAccountConnected) {
deleteChartLines();
}
}, [isAccountConnected]);
useEffect(() => {
if (isChartReady && tvWidget) {
if (tvWidget && isChartReady) {
tvWidget.onChartReady(() => {
tvWidget.chart().dataReady(() => {
if (showOrderLines) {
displayButton?.classList?.add('order-lines-active');
drawOrderLines();
drawPositionLine();
} else {
displayButton?.classList?.remove('order-lines-active');
deleteChartLines();
}
});
@@ -84,13 +78,13 @@ export const useChartLines = ({
const key = currentMarketPositionData.id;
const price = MustBigNumber(entryPrice).toNumber();
const maybePositionLine = chartLinesRef.current[key]?.line;
const maybePositionLine = chartLines[key]?.line;
const shouldShow = size && size !== 0;
if (!shouldShow) {
if (maybePositionLine) {
maybePositionLine.remove();
delete chartLinesRef.current[key];
delete chartLines[key];
return;
}
} else {
@@ -112,9 +106,9 @@ export const useChartLines = ({
.setQuantity(quantity);
if (positionLine) {
const chartLine: ChartLine = { line: positionLine, chartLineType: 'position' };
const chartLine = { line: positionLine, chartLineType: 'position' };
setLineColors({ chartLine: chartLine });
chartLinesRef.current[key] = chartLine;
chartLines[key] = chartLine;
}
}
}
@@ -149,12 +143,12 @@ export const useChartLines = ({
!cancelReason &&
(status === AbacusOrderStatus.open || status === AbacusOrderStatus.untriggered);
const maybeOrderLine = chartLinesRef.current[key]?.line;
const maybeOrderLine = chartLines[key]?.line;
if (!shouldShow) {
if (maybeOrderLine) {
maybeOrderLine.remove();
delete chartLinesRef.current[key];
delete chartLines[key];
return;
}
} else {
@@ -176,7 +170,7 @@ export const useChartLines = ({
chartLineType: ORDER_SIDES[side.name],
};
setLineColors({ chartLine: chartLine });
chartLinesRef.current[key] = chartLine;
chartLines[key] = chartLine;
}
}
}
@@ -185,10 +179,10 @@ export const useChartLines = ({
};
const deleteChartLines = () => {
Object.values(chartLinesRef.current).forEach(({ line }) => {
Object.values(chartLines).forEach(({ line }) => {
line.remove();
});
chartLinesRef.current = {};
chartLines = {};
};
const setLineColors = ({ chartLine }: { chartLine: ChartLine }) => {
@@ -210,4 +204,6 @@ export const useChartLines = ({
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.
*/
useEffect(() => {
if (isWidgetReady && currentMarketId !== tvWidget?.activeChart().symbol()) {
if (currentMarketId && isWidgetReady) {
const resolution = savedResolution || selectedResolution;
tvWidget?.setSymbol(currentMarketId, resolution as ResolutionString, () => {});
}
+2 -5
View File
@@ -4,7 +4,7 @@ import styled, { type AnyStyledComponent, css } from 'styled-components';
import type { ResolutionString } from 'public/tradingview/charting_library';
import type { ChartLine, TvWidget } from '@/constants/tvchart';
import type { TvWidget } from '@/constants/tvchart';
import {
useChartLines,
@@ -27,16 +27,13 @@ export const TvChart = () => {
const displayButtonRef = useRef<HTMLElement | null>(null);
const displayButton = displayButtonRef.current;
const chartLinesRef = useRef<Record<string, ChartLine>>({});
const chartLines = chartLinesRef.current;
const { savedResolution } = useTradingView({ tvWidgetRef, displayButtonRef, setIsChartReady });
useChartMarketAndResolution({
tvWidget,
isWidgetReady,
savedResolution: savedResolution as ResolutionString | undefined,
});
useChartLines({ tvWidget, displayButton, isChartReady, chartLinesRef });
const { chartLines } = useChartLines({ tvWidget, displayButton, isChartReady });
useTradingViewTheme({ tvWidget, isWidgetReady, chartLines });
return (