@kodiak-finance/orderly-react-app 2.8.32-alpha.2 → 2.8.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -89,6 +89,32 @@ function getOrderExecutionReportMsg(data, symbolsInfo) {
|
|
|
89
89
|
}
|
|
90
90
|
var ORDERLY_ORDER_SOUND_ALERT_KEY = "orderly_order_sound_alert";
|
|
91
91
|
var ORDERLY_TRADING_TOAST_ALERT_KEY = "orderly_trading_toast_alert";
|
|
92
|
+
var getStoredBoolean = (key, fallback) => {
|
|
93
|
+
if (typeof window === "undefined") {
|
|
94
|
+
return fallback;
|
|
95
|
+
}
|
|
96
|
+
const value = window.localStorage.getItem(key);
|
|
97
|
+
if (value === null) {
|
|
98
|
+
return fallback;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
const parsed = JSON.parse(value);
|
|
102
|
+
if (typeof parsed === "boolean") {
|
|
103
|
+
return parsed;
|
|
104
|
+
}
|
|
105
|
+
if (typeof parsed === "string") {
|
|
106
|
+
if (parsed.toLowerCase() === "true") {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if (parsed.toLowerCase() === "false") {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return fallback;
|
|
114
|
+
} catch {
|
|
115
|
+
return fallback;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
92
118
|
var useExecutionReport = () => {
|
|
93
119
|
const ee = orderlyHooks.useEventEmitter();
|
|
94
120
|
const symbolsInfo = orderlyHooks.useSymbolsInfo();
|
|
@@ -107,12 +133,13 @@ var useExecutionReport = () => {
|
|
|
107
133
|
true
|
|
108
134
|
);
|
|
109
135
|
const tradingToastAlertRef = orderlyHooks.useUpdatedRef(tradingToastAlert);
|
|
110
|
-
const
|
|
111
|
-
autoPlay: soundAutoPlay,
|
|
112
|
-
volume: 1
|
|
113
|
-
});
|
|
136
|
+
const soundAutoPlayRef = orderlyHooks.useUpdatedRef(soundAutoPlay);
|
|
114
137
|
const handler = orderlyHooks.useDebouncedCallback((data) => {
|
|
115
|
-
|
|
138
|
+
const latestTradingToastAlert = getStoredBoolean(
|
|
139
|
+
ORDERLY_TRADING_TOAST_ALERT_KEY,
|
|
140
|
+
tradingToastAlertRef.current
|
|
141
|
+
);
|
|
142
|
+
if (!latestTradingToastAlert) {
|
|
116
143
|
return;
|
|
117
144
|
}
|
|
118
145
|
const showToast = (data2) => {
|
|
@@ -120,15 +147,23 @@ var useExecutionReport = () => {
|
|
|
120
147
|
data2,
|
|
121
148
|
symbolsInfoRef.current
|
|
122
149
|
);
|
|
123
|
-
const
|
|
150
|
+
const shouldPlaySound = getStoredBoolean(
|
|
151
|
+
ORDERLY_ORDER_SOUND_ALERT_KEY,
|
|
152
|
+
soundAutoPlayRef.current
|
|
153
|
+
) && latestTradingToastAlert && (status === orderlyTypes.OrderStatus.FILLED || status === orderlyTypes.OrderStatus.PARTIAL_FILLED || status === orderlyTypes.OrderStatus.CANCELLED);
|
|
154
|
+
if (shouldPlaySound && src) {
|
|
155
|
+
const audio = new Audio(src);
|
|
156
|
+
audio.volume = 1;
|
|
157
|
+
audio.play().catch(() => {
|
|
158
|
+
});
|
|
159
|
+
}
|
|
124
160
|
const orderType = data2.algo_type || data2.type;
|
|
125
161
|
if (title && msg) {
|
|
126
162
|
orderlyUi.toast.success(
|
|
127
163
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
128
164
|
title,
|
|
129
165
|
/* @__PURE__ */ jsxRuntime.jsx("br", {}),
|
|
130
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "orderly-text-white/[0.54] orderly-text-xs", children: msg })
|
|
131
|
-
isFilled && audioElement
|
|
166
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "orderly-text-white/[0.54] orderly-text-xs", children: msg })
|
|
132
167
|
] }),
|
|
133
168
|
{ id: orderType }
|
|
134
169
|
);
|