Skip to content

Commit

Permalink
chore: clean up statsig flags for order modification (#1311)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinaszheng authored Nov 19, 2024
1 parent e374b07 commit c0eb02f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/constants/statsig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export type StatsigConfigType = Record<StatsigFlags, boolean>;
export enum StatsigFlags {
ffShowPredictionMarketsUi = 'ff_show_prediction_markets_ui',
ffEnableKeplr = 'ff_enable_keplr',
ffOrderModificationFromChart = 'ff_order_modification_from_chart',
ffEnableAffiliates = 'ff_enable_affiliates',
ffLimitOrdersFromChart = 'ff_limit_orders_from_chart',
ffEnableLimitClose = 'ff_enable_limit_close',
ffEnableTimestampNonce = 'ff_enable_timestamp_nonce',
ffEnableFunkit = 'ff_enable_funkit',
Expand Down
7 changes: 1 addition & 6 deletions src/hooks/tradingView/useChartLines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { AnalyticsEvents } from '@/constants/analytics';
import { TOGGLE_ACTIVE_CLASS_NAME } from '@/constants/charts';
import { DEFAULT_SOMETHING_WENT_WRONG_ERROR_PARAMS } from '@/constants/errors';
import { STRING_KEYS } from '@/constants/localization';
import { StatsigFlags } from '@/constants/statsig';
import { ORDER_TYPE_STRINGS, TradeTypes, type OrderType } from '@/constants/trade';
import type { ChartLine, PositionLineType, TvWidget } from '@/constants/tvchart';

Expand Down Expand Up @@ -44,7 +43,6 @@ import { isOrderStatusOpen } from '@/lib/orders';
import { getChartLineColors } from '@/lib/tradingView/utils';

import { useCustomNotification } from '../useCustomNotification';
import { useStatsigGateValue } from '../useStatsig';
import { useStringGetter } from '../useStringGetter';

const CHART_LINE_FONT = 'bold 10px Satoshi';
Expand Down Expand Up @@ -82,8 +80,6 @@ export const useChartLines = ({
shallowEqual
);

const canModifyOrdersFromChart = useStatsigGateValue(StatsigFlags.ffOrderModificationFromChart);

const runOnChartReady = useCallback(
(callback: () => void) => {
if (tvWidget) {
Expand Down Expand Up @@ -384,7 +380,7 @@ export const useChartLines = ({
setLineColorsAndFont({ chartLine });
chartLinesRef.current[key] = chartLine;
}
if (canModifyOrdersFromChart && canModifyOrderTypeFromChart(order)) {
if (canModifyOrderTypeFromChart(order)) {
orderLine?.onMove(() => onMoveOrderLine(order, orderLine));
}

Expand All @@ -404,7 +400,6 @@ export const useChartLines = ({
currentMarketOrders,
stringGetter,
tvWidget,
canModifyOrdersFromChart,
setLineColorsAndFont,
onMoveOrderLine,
dispatch,
Expand Down
6 changes: 2 additions & 4 deletions src/hooks/tradingView/useTradingViewLimitOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export function useTradingViewLimitOrder(
const stringGetter = useStringGetter();
const isUserConnected = useAppSelector(getIsAccountConnected);

const canDraftLimitOrders = true; // useStatsigGateValue(StatsigFlags.ffLimitOrdersFromChart);

// Every time we call tvChartWidget.onContextMenu, a new callback is _added_ and there is no way to remove previously
// added menu options. So, instead of creating a new callback and calling .onContextMenu every time these state variable
// change, only pass in one stable callback on chart load that refers to updated state values through a ref
Expand All @@ -43,7 +41,7 @@ export function useTradingViewLimitOrder(

return useCallback(
(_: number, price: number) => {
if (!canDraftLimitOrders || !userConnectedRef.current || price < 0 || !marketIdRef.current) {
if (!userConnectedRef.current || price < 0 || !marketIdRef.current) {
return [];
}

Expand Down Expand Up @@ -83,6 +81,6 @@ export function useTradingViewLimitOrder(
},
];
},
[canDraftLimitOrders, dispatch, stringGetter]
[dispatch, stringGetter]
);
}

0 comments on commit c0eb02f

Please sign in to comment.