clean code
This commit is contained in:
parent
df7f22a38b
commit
4add3521b3
@ -1,6 +1,6 @@
|
|||||||
<script lang='ts'>
|
<script lang='ts'>
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { screenWidth, userRegion, numberOfUnreadNotification, etfTicker, stockTicker, isOpen } from '$lib/store';
|
import { screenWidth, numberOfUnreadNotification, etfTicker, stockTicker, isOpen } from '$lib/store';
|
||||||
import notifySound from '$lib/audio/options-flow-reader.mp3';
|
import notifySound from '$lib/audio/options-flow-reader.mp3';
|
||||||
import UpgradeToPro from '$lib/components/UpgradeToPro.svelte';
|
import UpgradeToPro from '$lib/components/UpgradeToPro.svelte';
|
||||||
import { abbreviateNumber } from '$lib/utils';
|
import { abbreviateNumber } from '$lib/utils';
|
||||||
@ -11,16 +11,6 @@
|
|||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
|
|
||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
|
||||||
let wsURL;
|
|
||||||
|
|
||||||
userRegion?.subscribe(value => {
|
|
||||||
if (usRegion?.includes(value)) {
|
|
||||||
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
|
||||||
} else {
|
|
||||||
wsURL = import.meta.env.VITE_EU_WS_URL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let rawData = [];
|
let rawData = [];
|
||||||
let filterList = [];
|
let filterList = [];
|
||||||
@ -64,6 +54,32 @@
|
|||||||
let optionExecutionEstimate;
|
let optionExecutionEstimate;
|
||||||
let optionExchange;
|
let optionExchange;
|
||||||
|
|
||||||
|
/*
|
||||||
|
async function infiniteHandler({ detail: { loaded, complete, error } }) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
const lastId = rawData?.at(-1)?.id;
|
||||||
|
const postData = {'lastId': lastId};
|
||||||
|
const response = await fetch(data?.apiURL + '/options-flow-feed', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||||
|
},
|
||||||
|
body: JSON.stringify(postData),
|
||||||
|
});
|
||||||
|
const newData = await response.json();
|
||||||
|
if(newData?.length === 0) {
|
||||||
|
complete();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rawData = [...rawData,...newData];
|
||||||
|
loaded();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
function toggleMode()
|
function toggleMode()
|
||||||
{
|
{
|
||||||
if ($isOpen) {
|
if ($isOpen) {
|
||||||
@ -120,7 +136,7 @@ function handleViewData(optionData) {
|
|||||||
async function websocketRealtimeData() {
|
async function websocketRealtimeData() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
socket = new WebSocket(wsURL+"/options-flow-reader");
|
socket = new WebSocket(data?.wsURL+"/options-flow-reader");
|
||||||
|
|
||||||
|
|
||||||
socket.addEventListener('message', (event) => {
|
socket.addEventListener('message', (event) => {
|
||||||
|
|||||||
@ -22,6 +22,7 @@ const checkMarketHour = async () => {
|
|||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||||
|
|
||||||
let apiURL;
|
let apiURL;
|
||||||
|
let wsURL;
|
||||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||||
|
|
||||||
|
|
||||||
@ -29,8 +30,10 @@ userRegion.subscribe(value => {
|
|||||||
|
|
||||||
if (usRegion?.includes(value)) {
|
if (usRegion?.includes(value)) {
|
||||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||||
|
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
||||||
} else {
|
} else {
|
||||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||||
|
wsURL = import.meta.env.VITE_EU_WS_URL;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -56,6 +59,7 @@ export const load = async () => {
|
|||||||
|
|
||||||
// Make sure to return a promise
|
// Make sure to return a promise
|
||||||
return {
|
return {
|
||||||
getOptionsFlowFeed: await getOptionsFlowFeed()
|
getOptionsFlowFeed: await getOptionsFlowFeed(),
|
||||||
|
wsURL,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<script lang='ts'>
|
<script lang='ts'>
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import { screenWidth, userRegion, numberOfUnreadNotification, etfTicker, stockTicker, isOpen } from '$lib/store';
|
import { screenWidth, numberOfUnreadNotification, etfTicker, stockTicker, isOpen } from '$lib/store';
|
||||||
import notifySound from '$lib/audio/options-flow-reader.mp3';
|
import notifySound from '$lib/audio/options-flow-reader.mp3';
|
||||||
import UpgradeToPro from '$lib/components/UpgradeToPro.svelte';
|
import UpgradeToPro from '$lib/components/UpgradeToPro.svelte';
|
||||||
import { abbreviateNumber } from '$lib/utils';
|
import { abbreviateNumber } from '$lib/utils';
|
||||||
@ -12,17 +12,6 @@
|
|||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
|
|
||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
|
||||||
let wsURL;
|
|
||||||
|
|
||||||
userRegion?.subscribe(value => {
|
|
||||||
if (usRegion?.includes(value)) {
|
|
||||||
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
|
||||||
} else {
|
|
||||||
wsURL = import.meta.env.VITE_EU_WS_URL;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let rawData = [];
|
let rawData = [];
|
||||||
let filterList = [];
|
let filterList = [];
|
||||||
|
|
||||||
@ -121,7 +110,7 @@ function handleViewData(optionData) {
|
|||||||
async function websocketRealtimeData() {
|
async function websocketRealtimeData() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
socket = new WebSocket(wsURL+"/options-zero-dte-reader");
|
socket = new WebSocket(data?.wsURL+"/options-zero-dte-reader");
|
||||||
|
|
||||||
|
|
||||||
socket.addEventListener('message', (event) => {
|
socket.addEventListener('message', (event) => {
|
||||||
|
|||||||
@ -22,6 +22,7 @@ const checkMarketHour = async () => {
|
|||||||
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
const usRegion = ['cle1','iad1','pdx1','sfo1'];
|
||||||
|
|
||||||
let apiURL;
|
let apiURL;
|
||||||
|
let wsURL;
|
||||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||||
|
|
||||||
|
|
||||||
@ -29,8 +30,10 @@ userRegion.subscribe(value => {
|
|||||||
|
|
||||||
if (usRegion?.includes(value)) {
|
if (usRegion?.includes(value)) {
|
||||||
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||||
|
wsURL = import.meta.env.VITE_USEAST_WS_URL;
|
||||||
} else {
|
} else {
|
||||||
apiURL = import.meta.env.VITE_EU_API_URL;
|
apiURL = import.meta.env.VITE_EU_API_URL;
|
||||||
|
wsURL = import.meta.env.VITE_EU_WS_URL;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user