chore: sync project updates
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"0": "useTvMonitorPage",
|
||||
"1": "ref_utils",
|
||||
"2": "index.vue",
|
||||
"3": "productPrice.ts",
|
||||
"4": "forceReconnect",
|
||||
"5": "api/products.ts",
|
||||
"6": "priceSocket.ts",
|
||||
"7": "connect",
|
||||
"8": "runFallbackPoll",
|
||||
"9": "AuthPriceStream",
|
||||
"10": "initPriceRealtimeChannel"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"0": "fedf686fef62ba26", "1": "67d1701e4c6cea74", "2": "97089a21ad1adc51", "3": "58d20669e0f3fce4", "4": "0a1bda70e7876267", "5": "8d51306eb7d0daf2", "6": "e5b38e4db98b7ce1", "7": "34e9bd652058d950", "8": "7b0e3ddd528dd627", "9": "08b88f1fc8c91c56", "10": "e498d0b00a604ad7"}
|
||||
@@ -0,0 +1 @@
|
||||
.
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"0": "useTvMonitorPage",
|
||||
"1": "useTvMonitorPage.ts",
|
||||
"2": "index.vue",
|
||||
"3": "productPrice.ts",
|
||||
"4": "getProductBaseBuyPrice",
|
||||
"5": "ref_models",
|
||||
"6": "isTvProductPriceInactive",
|
||||
"7": "applyPriceOffsetPercent"
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
# Graph Report - ghatreh_user (2026-09-27)
|
||||
|
||||
## Corpus Check
|
||||
- 598 files · ~506,745 words
|
||||
- Verdict: corpus is large enough that graph structure adds value.
|
||||
- Unclassified: 51 file(s) not represented in the graph (top: .less 25, .eot 6, .ttf 6)
|
||||
|
||||
## Summary
|
||||
- 84 nodes · 154 edges · 8 communities
|
||||
- Extraction: 91% EXTRACTED · 9% INFERRED · 0% AMBIGUOUS · INFERRED: 14 edges (avg confidence: 0.85)
|
||||
- Token cost: 0 input · 0 output
|
||||
|
||||
## Graph Freshness
|
||||
- Built from commit: `8083c4f0`
|
||||
- Run `git rev-parse HEAD` and compare to check if the graph is stale.
|
||||
- Run `graphify update .` after code changes (no API cost).
|
||||
|
||||
## Community Hubs (Navigation)
|
||||
- useTvMonitorPage
|
||||
- useTvMonitorPage.ts
|
||||
- index.vue
|
||||
- productPrice.ts
|
||||
- getProductBaseBuyPrice
|
||||
- ref_models
|
||||
- isTvProductPriceInactive
|
||||
- applyPriceOffsetPercent
|
||||
|
||||
## God Nodes (most connected - your core abstractions)
|
||||
1. `useTvMonitorPage()` - 25 edges
|
||||
2. `getProductBaseBuyPrice()` - 10 edges
|
||||
3. `getProductBuyPrice()` - 7 edges
|
||||
4. `getProductBaseSellPrice()` - 6 edges
|
||||
5. `getProductSellPrice()` - 6 edges
|
||||
6. `productUsesLastPriceIfZero()` - 5 edges
|
||||
7. `applyPriceOffsetPercent()` - 5 edges
|
||||
8. `isProductPriceInactive()` - 5 edges
|
||||
9. `formatTvPrice()` - 5 edges
|
||||
10. `cashFeeOptions()` - 4 edges
|
||||
|
||||
## Surprising Connections (you probably didn't know these)
|
||||
- `useTvMonitorPage()` --indirect_call--> `isShowOnTv()` [INFERRED]
|
||||
src/views/tv/composables/useTvMonitorPage.ts → src/views/tv/composables/useTvMonitorPage.ts _Bridges community 1 → community 0_
|
||||
- `colleagueSideUnit()` --calls--> `getColleagueSourcedUnitPrice()` [EXTRACTED]
|
||||
src/utils/productPrice.ts → src/utils/productPrice.ts _Bridges community 4 → community 7_
|
||||
- `getProductBuyPrice()` --calls--> `getProductBaseBuyPrice()` [EXTRACTED]
|
||||
src/utils/productPrice.ts → src/utils/productPrice.ts _Bridges community 4 → community 3_
|
||||
- `getTvProductBuyPrice()` --calls--> `getProductBuyPrice()` [EXTRACTED]
|
||||
src/utils/productPrice.ts → src/utils/productPrice.ts _Bridges community 3 → community 6_
|
||||
- `isTvProductPriceInactive()` --calls--> `isProductPriceInactive()` [EXTRACTED]
|
||||
src/utils/productPrice.ts → src/utils/productPrice.ts _Bridges community 4 → community 6_
|
||||
|
||||
## Import Cycles
|
||||
- None detected.
|
||||
|
||||
## Communities (8 total, 0 thin omitted)
|
||||
|
||||
### Community 0 - "useTvMonitorPage"
|
||||
Cohesion: 0.14
|
||||
Nodes (17): floorTvToman(), formatTvPrice(), parseTvNews(), useTvMonitorPage(), hideCursorSoon(), isProductTvInactive(), liveQuoteLabel(), loadProducts() (+9 more)
|
||||
|
||||
### Community 1 - "useTvMonitorPage.ts"
|
||||
Cohesion: 0.17
|
||||
Nodes (15): ref_api, ref_assets, ref_moment, ref_moment_jalaali, ref_store, ref_utils, ref_vue, ref_vueuse_core (+7 more)
|
||||
|
||||
### Community 2 - "index.vue"
|
||||
Cohesion: 0.19
|
||||
Nodes (15): ref_components, ref_views, coinColumns, extraTickerLoop, loopNews(), loopTicker(), marqueeCopies(), newsDuration() (+7 more)
|
||||
|
||||
### Community 3 - "productPrice.ts"
|
||||
Cohesion: 0.44
|
||||
Nodes (9): buyCashFee(), cashFeeOptions(), getProductBuyPrice(), getProductSellPrice(), hasProductUnitWeight(), isProductWithoutDisplayPrice(), productPriceAmountFactor(), productUsesLiveBoardQuote() (+1 more)
|
||||
|
||||
### Community 4 - "getProductBaseBuyPrice"
|
||||
Cohesion: 0.43
|
||||
Nodes (8): colleagueSideUnit(), getProductBaseBuyPrice(), getProductBaseSellPrice(), getReferenceProductBaseBuyPrice(), hasReferenceReadingMethod(), isProductPriceInactive(), isProductVisible(), productUsesLastPriceIfZero()
|
||||
|
||||
### Community 5 - "ref_models"
|
||||
Cohesion: 0.40
|
||||
Nodes (4): ref_models, CountPInventory, PInventory, Product
|
||||
|
||||
### Community 6 - "isTvProductPriceInactive"
|
||||
Cohesion: 0.50
|
||||
Nodes (5): getTvProductBuyPrice(), getTvProductSellPrice(), isTvProductPriceInactive(), tvBuyUnitPrice(), tvSellUnitPrice()
|
||||
|
||||
### Community 7 - "applyPriceOffsetPercent"
|
||||
Cohesion: 0.67
|
||||
Nodes (3): applyPriceOffsetPercent(), getColleagueSourcedUnitPrice(), resolvePriceOffsetRatio()
|
||||
|
||||
## Knowledge Gaps
|
||||
- **6 isolated node(s):** `Product`, `PInventory`, `CountPInventory`, `{ theme, themeVars, toggleTheme }`, `{
|
||||
rootEl,
|
||||
brandName,
|
||||
brandLogo,
|
||||
nowLabel,
|
||||
dateLabel,
|
||||
parsianCoins,
|
||||
bankCoins,
|
||||
hasCoinBoard,
|
||||
hasBoardContent,
|
||||
tickerProducts,
|
||||
tickerTitle,
|
||||
extraTickerProducts,
|
||||
extraTickerTitle,
|
||||
tvNewsItems,
|
||||
newsTickerTitle,
|
||||
statusBanner,
|
||||
showMainQuote,
|
||||
mainQuoteReady,
|
||||
mainQuoteReady,
|
||||
liveBuy,
|
||||
liveSell,
|
||||
isLive,
|
||||
isFullscreen,
|
||||
cursorHidden,
|
||||
loading,
|
||||
productWeightLabel,
|
||||
tickerItemLabel,
|
||||
isProductTvInactive,
|
||||
productBuyLabel,
|
||||
productSellLabel,
|
||||
liveQuoteLabel,
|
||||
toggleFullscreen,
|
||||
}` (+1 more)
|
||||
These have ≤1 connection - possible missing edges or undocumented components. (Counts symbols only; 18 node(s) total have ≤1 connection when file, concept and rationale nodes are included.)
|
||||
|
||||
## Suggested Questions
|
||||
_Questions this graph is uniquely positioned to answer:_
|
||||
|
||||
- **Why does `useTvMonitorPage()` connect `useTvMonitorPage` to `useTvMonitorPage.ts`?**
|
||||
_High betweenness centrality (0.342) - this node is a cross-community bridge._
|
||||
- **Why does `formatTvPrice()` connect `useTvMonitorPage` to `useTvMonitorPage.ts`?**
|
||||
_High betweenness centrality (0.026) - this node is a cross-community bridge._
|
||||
- **Why does `getProductBaseBuyPrice()` connect `getProductBaseBuyPrice` to `productPrice.ts`, `applyPriceOffsetPercent`?**
|
||||
_High betweenness centrality (0.004) - this node is a cross-community bridge._
|
||||
- **Are the 13 inferred relationships involving `useTvMonitorPage()` (e.g. with `isBankCoin()` and `isGoldBar()`) actually correct?**
|
||||
_`useTvMonitorPage()` has 13 INFERRED edges - model-reasoned connections that need verification._
|
||||
- **What connects `Product`, `PInventory`, `CountPInventory` to the rest of the system?**
|
||||
_6 weakly-connected nodes found - possible documentation gaps or missing edges._
|
||||
- **Should `useTvMonitorPage` be split into smaller, more focused modules?**
|
||||
_Cohesion score 0.1380952380952381 - nodes in this community are weakly interconnected._
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,183 @@
|
||||
# Graph Report - ghatreh_user (2026-09-27)
|
||||
|
||||
## Corpus Check
|
||||
- 598 files · ~506,859 words
|
||||
- Verdict: corpus is large enough that graph structure adds value.
|
||||
- Unclassified: 51 file(s) not represented in the graph (top: .less 25, .eot 6, .ttf 6)
|
||||
|
||||
## Summary
|
||||
- 159 nodes · 338 edges · 11 communities (10 shown, 1 thin omitted)
|
||||
- Extraction: 93% EXTRACTED · 7% INFERRED · 0% AMBIGUOUS · INFERRED: 24 edges (avg confidence: 0.85)
|
||||
- Token cost: 0 input · 0 output
|
||||
|
||||
## Graph Freshness
|
||||
- Built from commit: `bc64ff47`
|
||||
- Run `git rev-parse HEAD` and compare to check if the graph is stale.
|
||||
- Run `graphify update .` after code changes (no API cost).
|
||||
|
||||
## Community Hubs (Navigation)
|
||||
- useTvMonitorPage
|
||||
- ref_utils
|
||||
- index.vue
|
||||
- productPrice.ts
|
||||
- forceReconnect
|
||||
- api/products.ts
|
||||
- priceSocket.ts
|
||||
- connect
|
||||
- runFallbackPoll
|
||||
- AuthPriceStream
|
||||
- initPriceRealtimeChannel
|
||||
|
||||
## God Nodes (most connected - your core abstractions)
|
||||
1. `useTvMonitorPage()` - 26 edges
|
||||
2. `connect()` - 15 edges
|
||||
3. `getProductBaseBuyPrice()` - 10 edges
|
||||
4. `touchStreamActivity()` - 9 edges
|
||||
5. `bindStreamEvents()` - 9 edges
|
||||
6. `forceReconnect()` - 9 edges
|
||||
7. `runFallbackPoll()` - 8 edges
|
||||
8. `maybeShowNetworkAlert()` - 8 edges
|
||||
9. `disconnect()` - 8 edges
|
||||
10. `handleStreamLost()` - 7 edges
|
||||
|
||||
## Surprising Connections (you probably didn't know these)
|
||||
- `connect()` --calls--> `AuthPriceStream` [EXTRACTED]
|
||||
src/utils/priceSocket.ts → src/utils/priceSocket.ts _Bridges community 9 → community 7_
|
||||
- `connect()` --calls--> `resolveStreamUrl()` [EXTRACTED]
|
||||
src/utils/priceSocket.ts → src/utils/priceSocket.ts _Bridges community 10 → community 7_
|
||||
- `forceReconnect()` --calls--> `clearReconnectTimer()` [EXTRACTED]
|
||||
src/utils/priceSocket.ts → src/utils/priceSocket.ts _Bridges community 7 → community 4_
|
||||
- `connect()` --calls--> `touchStreamActivity()` [EXTRACTED]
|
||||
src/utils/priceSocket.ts → src/utils/priceSocket.ts _Bridges community 1 → community 7_
|
||||
- `connect()` --calls--> `stopFallbackPolling()` [EXTRACTED]
|
||||
src/utils/priceSocket.ts → src/utils/priceSocket.ts _Bridges community 8 → community 7_
|
||||
|
||||
## Import Cycles
|
||||
- None detected.
|
||||
|
||||
## Communities (11 total, 1 thin omitted)
|
||||
|
||||
### Community 0 - "useTvMonitorPage"
|
||||
Cohesion: 0.09
|
||||
Nodes (32): ref_api, ref_assets, ref_moment, ref_moment_jalaali, ref_vue, ref_vueuse_core, bankCoinRank(), floorTvToman() (+24 more)
|
||||
|
||||
### Community 1 - "ref_utils"
|
||||
Cohesion: 0.23
|
||||
Nodes (15): ref_composables, ref_store, ref_utils, applyAppNotificationFromStream(), applyLastFromStream(), applySettingsFromStream(), applyUnreadCountFromStreamPayload(), bindStreamEvents() (+7 more)
|
||||
|
||||
### Community 2 - "index.vue"
|
||||
Cohesion: 0.21
|
||||
Nodes (14): ref_components, coinColumns, extraTickerLoop, loopNews(), loopTicker(), marqueeCopies(), newsDuration(), newsTickerDuration (+6 more)
|
||||
|
||||
### Community 3 - "productPrice.ts"
|
||||
Cohesion: 0.19
|
||||
Nodes (25): applyPriceOffsetPercent(), buyCashFee(), cashFeeOptions(), colleagueSideUnit(), getColleagueSourcedUnitPrice(), getProductBaseBuyPrice(), getProductBaseSellPrice(), getProductBuyPrice() (+17 more)
|
||||
|
||||
### Community 4 - "forceReconnect"
|
||||
Cohesion: 0.21
|
||||
Nodes (16): bindBrowserNetworkListeners(), forceReconnect(), isPageVisible(), maybeShowNetworkAlert(), notifyPriceLastFetchFailed(), onBrowserOffline(), onBrowserOnline(), onPageShow() (+8 more)
|
||||
|
||||
### Community 5 - "api/products.ts"
|
||||
Cohesion: 0.15
|
||||
Nodes (5): ref_models, TvServerTime, CountPInventory, PInventory, Product
|
||||
|
||||
### Community 6 - "priceSocket.ts"
|
||||
Cohesion: 0.22
|
||||
Nodes (4): ref_ant_design_vue, getPriceSourceStaleMs(), isMobileDevice(), isRealPriceOutage()
|
||||
|
||||
### Community 7 - "connect"
|
||||
Cohesion: 0.36
|
||||
Nodes (10): clearConnectingLifecycle(), clearReconnectTimer(), connect(), disconnect(), disconnectSourceOnly(), handleStreamLost(), markConnectingLifecycle(), scheduleReconnect() (+2 more)
|
||||
|
||||
### Community 8 - "runFallbackPoll"
|
||||
Cohesion: 0.38
|
||||
Nodes (7): ref_views, clearFallbackPollTimer(), clearPriceNetworkAlert(), runFallbackPoll(), scheduleFallbackPoll(), startFallbackPolling(), stopFallbackPolling()
|
||||
|
||||
### Community 10 - "initPriceRealtimeChannel"
|
||||
Cohesion: 0.60
|
||||
Nodes (5): initPriceRealtimeChannel(), isPriceWebSocketEnabled(), isTruthySetting(), resolveStreamPath(), resolveStreamUrl()
|
||||
|
||||
## Knowledge Gaps
|
||||
- **7 isolated node(s):** `TvServerTime`, `{ theme, themeVars, toggleTheme }`, `{
|
||||
rootEl,
|
||||
brandName,
|
||||
brandLogo,
|
||||
nowLabel,
|
||||
dateLabel,
|
||||
parsianCoins,
|
||||
bankCoins,
|
||||
hasCoinBoard,
|
||||
hasBoardContent,
|
||||
tickerProducts,
|
||||
tickerTitle,
|
||||
extraTickerProducts,
|
||||
extraTickerTitle,
|
||||
tvNewsItems,
|
||||
newsTickerTitle,
|
||||
statusBanner,
|
||||
showMainQuote,
|
||||
mainQuoteReady,
|
||||
mainQuoteReady,
|
||||
liveBuy,
|
||||
liveSell,
|
||||
isLive,
|
||||
isFullscreen,
|
||||
cursorHidden,
|
||||
loading,
|
||||
productWeightLabel,
|
||||
tickerItemLabel,
|
||||
isProductTvInactive,
|
||||
productBuyLabel,
|
||||
productSellLabel,
|
||||
liveQuoteLabel,
|
||||
toggleFullscreen,
|
||||
}`, `{ setColListRef, pauseColAuto, resumeColAuto }`, `CountPInventory` (+2 more)
|
||||
These have ≤1 connection - possible missing edges or undocumented components. (Counts symbols only; 29 node(s) total have ≤1 connection when file, concept and rationale nodes are included.)
|
||||
- **1 thin communities (<3 nodes) omitted from report** — run `graphify query` to explore isolated nodes.
|
||||
|
||||
## Suggested Questions
|
||||
_Questions this graph is uniquely positioned to answer:_
|
||||
|
||||
- **Why does `AuthPriceStream` connect `AuthPriceStream` to `priceSocket.ts`, `connect`?**
|
||||
_High betweenness centrality (0.043) - this node is a cross-community bridge._
|
||||
- **Why does `runFallbackPoll()` connect `runFallbackPoll` to `ref_utils`, `forceReconnect`, `priceSocket.ts`?**
|
||||
_High betweenness centrality (0.020) - this node is a cross-community bridge._
|
||||
- **Are the 13 inferred relationships involving `useTvMonitorPage()` (e.g. with `isBankCoin()` and `isGoldBar()`) actually correct?**
|
||||
_`useTvMonitorPage()` has 13 INFERRED edges - model-reasoned connections that need verification._
|
||||
- **What connects `TvServerTime`, `{ theme, themeVars, toggleTheme }`, `{
|
||||
rootEl,
|
||||
brandName,
|
||||
brandLogo,
|
||||
nowLabel,
|
||||
dateLabel,
|
||||
parsianCoins,
|
||||
bankCoins,
|
||||
hasCoinBoard,
|
||||
hasBoardContent,
|
||||
tickerProducts,
|
||||
tickerTitle,
|
||||
extraTickerProducts,
|
||||
extraTickerTitle,
|
||||
tvNewsItems,
|
||||
newsTickerTitle,
|
||||
statusBanner,
|
||||
showMainQuote,
|
||||
mainQuoteReady,
|
||||
mainQuoteReady,
|
||||
liveBuy,
|
||||
liveSell,
|
||||
isLive,
|
||||
isFullscreen,
|
||||
cursorHidden,
|
||||
loading,
|
||||
productWeightLabel,
|
||||
tickerItemLabel,
|
||||
isProductTvInactive,
|
||||
productBuyLabel,
|
||||
productSellLabel,
|
||||
liveQuoteLabel,
|
||||
toggleFullscreen,
|
||||
}` to the rest of the system?**
|
||||
_7 weakly-connected nodes found - possible documentation gaps or missing edges._
|
||||
- **Should `useTvMonitorPage` be split into smaller, more focused modules?**
|
||||
_Cohesion score 0.09365079365079365 - nodes in this community are weakly interconnected._
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -282,21 +282,28 @@ export function notifyPriceLastFetchFailed() {
|
||||
void maybeShowNetworkAlert()
|
||||
}
|
||||
|
||||
function onTvBoard() {
|
||||
if (typeof window === 'undefined') return false
|
||||
const path = window.location.pathname.replace(/\/+$/, '') || '/'
|
||||
return path === '/tv' || path.endsWith('/tv') || path === '/monitor' || path.endsWith('/monitor')
|
||||
}
|
||||
|
||||
async function runFallbackPoll() {
|
||||
if (!priceWssEnabled.value || priceSocketConnected.value) {
|
||||
if (onTvBoard() || tvStreamKey || !priceWssEnabled.value || priceSocketConnected.value) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const { getLastPrices, hasRecentPriceFromSource } = await import('@/utils/price')
|
||||
const { refreshProductsPageData } = await import(
|
||||
'@/views/base/products/composables/useProductsPageData'
|
||||
)
|
||||
const jobs: Promise<unknown>[] = [getLastPrices()]
|
||||
if (!tvStreamKey) {
|
||||
const { refreshProductsPageData } = await import(
|
||||
'@/views/base/products/composables/useProductsPageData'
|
||||
)
|
||||
jobs.push(refreshProductsPageData())
|
||||
}
|
||||
|
||||
const [priceResult] = await Promise.allSettled([
|
||||
getLastPrices(),
|
||||
refreshProductsPageData(),
|
||||
])
|
||||
const [priceResult] = await Promise.allSettled(jobs)
|
||||
|
||||
const priceOk =
|
||||
priceResult.status === 'fulfilled'
|
||||
@@ -743,6 +750,10 @@ function unbindBrowserNetworkListeners() {
|
||||
window.removeEventListener('offline', onBrowserOffline)
|
||||
}
|
||||
|
||||
export function isTvStreamActive() {
|
||||
return Boolean(tvStreamKey)
|
||||
}
|
||||
|
||||
export function startTvPriceStream(
|
||||
settingGetter: (key: string) => unknown,
|
||||
key: string,
|
||||
|
||||
@@ -182,14 +182,24 @@ function applyProductsList(products: Product[]) {
|
||||
productsPageLoading.value = false
|
||||
}
|
||||
|
||||
function onTvBoard() {
|
||||
if (typeof window === 'undefined') return false
|
||||
const path = window.location.pathname.replace(/\/+$/, '') || '/'
|
||||
return path === '/tv' || path.endsWith('/tv') || path === '/monitor' || path.endsWith('/monitor')
|
||||
}
|
||||
|
||||
/** قیمت enrich شده فقط در HTTP کامل است؛ slim SSE برای پرچمهاست */
|
||||
function scheduleCatalogRefreshFromStream() {
|
||||
if (onTvBoard()) return
|
||||
if (catalogStreamRefreshTimer) {
|
||||
clearTimeout(catalogStreamRefreshTimer)
|
||||
}
|
||||
catalogStreamRefreshTimer = setTimeout(() => {
|
||||
catalogStreamRefreshTimer = undefined
|
||||
void refreshProductsPageData()
|
||||
void import('@/utils/priceSocket').then(({ isTvStreamActive }) => {
|
||||
if (isTvStreamActive()) return
|
||||
void refreshProductsPageData()
|
||||
})
|
||||
}, 150)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { useFullscreen } from '@vueuse/core'
|
||||
import type { Product } from '@/models/products'
|
||||
import { getTvProducts, getTvServerTime } from '@/api/products'
|
||||
import { getConfigApp } from '@/utils/config'
|
||||
import { useSettingsStore } from '@/store/settingsStore'
|
||||
import { getProductBuyPrice, getProductSellPrice, getTvProductBuyPrice, getTvProductSellPrice } from '@/utils/productPrice'
|
||||
import { getLastPrices, lastPrice, startLastPricePolling, stopLastPricePolling } from '@/utils/price'
|
||||
import { getTvProductBuyPrice, getTvProductSellPrice } from '@/utils/productPrice'
|
||||
import { usePriceWithoutType } from '@/utils/usePrice'
|
||||
import { getStoreClosedMessage, isStoreClosedBySchedule, NO_QUOTE_MESSAGE } from '@/utils/storeHours'
|
||||
import { isMeltedTradeGroup, isMetalCommodityGroup } from '@/utils/productCategories'
|
||||
@@ -227,8 +226,7 @@ export function useTvMonitorPage() {
|
||||
|
||||
const mainTvProduct = computed(() => {
|
||||
void settingsStore.settingsRevision
|
||||
const raw = String(settingsStore.getSettingByKey('main_product') ?? '').trim()
|
||||
if (!raw) return null
|
||||
const raw = String(settingsStore.getSettingByKey('main_product') ?? '').trim() || '13'
|
||||
const match = catalogProducts.value.find(
|
||||
(product) => String(product.id) === raw || String(product.reading_method ?? '') === raw,
|
||||
)
|
||||
@@ -239,16 +237,8 @@ export function useTvMonitorPage() {
|
||||
|
||||
const showMainQuote = computed(() => !!mainTvProduct.value)
|
||||
|
||||
const liveBuy = computed(() => {
|
||||
void lastPrice.value
|
||||
const product = mainTvProduct.value
|
||||
return product ? getProductBuyPrice(product) : 0
|
||||
})
|
||||
const liveSell = computed(() => {
|
||||
void lastPrice.value
|
||||
const product = mainTvProduct.value
|
||||
return product ? getProductSellPrice(product) : 0
|
||||
})
|
||||
const liveBuy = computed(() => Number(mainTvProduct.value?.tv_price ?? 0) || 0)
|
||||
const liveSell = computed(() => Number(mainTvProduct.value?.tv_sell_price ?? 0) || 0)
|
||||
|
||||
const mainQuoteReady = computed(() => liveBuy.value > 0 || liveSell.value > 0)
|
||||
|
||||
@@ -374,6 +364,19 @@ export function useTvMonitorPage() {
|
||||
return label === '—' ? NO_QUOTE_MESSAGE : label
|
||||
}
|
||||
|
||||
function streamIsUp() {
|
||||
return priceSocketConnected.value || priceStreamLifecycle.value === 'open'
|
||||
}
|
||||
|
||||
function pollTvProducts() {
|
||||
if (streamIsUp()) return
|
||||
void loadProducts()
|
||||
}
|
||||
|
||||
watch(priceSocketConnected, (up) => {
|
||||
if (!up) pollTvProducts()
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
document.documentElement.classList.add(TV_HTML_CLASS)
|
||||
await syncServerClock()
|
||||
@@ -384,12 +387,10 @@ export function useTvMonitorPage() {
|
||||
document.addEventListener('visibilitychange', onVisibilityChange)
|
||||
await requestWakeLock()
|
||||
|
||||
startLastPricePolling()
|
||||
void getLastPrices()
|
||||
void loadProducts()
|
||||
listTimer = setInterval(() => {
|
||||
void loadProducts()
|
||||
void syncServerClock()
|
||||
pollTvProducts()
|
||||
}, REFRESH_MS)
|
||||
|
||||
document.title = `${brandName.value} | تابلو قیمت`
|
||||
@@ -404,7 +405,6 @@ export function useTvMonitorPage() {
|
||||
window.removeEventListener('mousemove', hideCursorSoon)
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange)
|
||||
void releaseWakeLock()
|
||||
stopLastPricePolling()
|
||||
stopTvPriceStream()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user