Fix bug that would flash opposite state of updateOBSTextVisibility for a split second on price update
This commit is contained in:
parent
382db88249
commit
8c5ee1faf2
10
main.js
10
main.js
|
@ -28,6 +28,10 @@ function restartCalculations() {
|
|||
calculationInterval = setInterval(checkStatusAndUpdateOBS, 5000);
|
||||
}
|
||||
|
||||
let obsVisibilityState = {
|
||||
makingMoney: null
|
||||
};
|
||||
|
||||
discordClient.login(discordToken);
|
||||
|
||||
discordClient.on('ready', async () => {
|
||||
|
@ -73,10 +77,8 @@ function updateEnvValue(key, value) {
|
|||
}
|
||||
|
||||
function createStatsEmbed(tokenData = {}) {
|
||||
// Function to format numbers with commas
|
||||
const formatNumber = (num) => new Intl.NumberFormat().format(num);
|
||||
|
||||
// Formatting the numbers using the formatNumber function
|
||||
const marketCapFormatted = tokenData.marketCap ? `$${formatNumber(tokenData.marketCap)}` : 'N/A';
|
||||
const priceFormatted = tokenData.price ? `$${formatNumber(tokenData.price)}` : 'N/A';
|
||||
const liquidityFormatted = tokenData.liquidity ? `$${formatNumber(tokenData.liquidity)}` : 'N/A';
|
||||
|
@ -215,8 +217,12 @@ const setSourceVisibility = (sourceName, visible) => {
|
|||
};
|
||||
|
||||
const updateOBSTextVisibility = (makingMoney) => {
|
||||
if (obsVisibilityState.makingMoney !== makingMoney) {
|
||||
setSourceVisibility("TextGreen", makingMoney);
|
||||
setSourceVisibility("TextRed", !makingMoney);
|
||||
|
||||
obsVisibilityState.makingMoney = makingMoney;
|
||||
}
|
||||
};
|
||||
|
||||
const checkStatusAndUpdateOBS = async () => {
|
||||
|
|
Loading…
Reference in New Issue