feat: catalog read cache (api + user apps) and clearer Zarrin accounting errors

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
s.esmaeili
2026-10-11 14:31:32 +03:30
co-authored by Cursor
parent 561addc676
commit 574fa1b4aa
53 changed files with 1241 additions and 401 deletions
@@ -40,12 +40,13 @@ import PageBar from '../../components/ui/PageBar.vue'
import Spinner from '../../components/Spinner.vue'
import SectionHead from '../../components/home/SectionHead.vue'
import ProductCard from '../../components/product/ProductCard.vue'
import { api, type ProductSummary } from '../../api/client'
import { useCatalogStore } from '../../stores/catalogStore'
const route = useRoute()
const catalog = useCatalogStore()
const loadingPage = ref(false)
const allProducts = ref<ProductSummary[]>([])
const allProducts = computed(() => catalog.products)
// legacy passed the collection's title through as ?page=<title>; kept, with a
// neutral fallback so the bar is never blank on a direct link.
@@ -56,9 +57,11 @@ const collectionProducts = computed(() =>
)
onMounted(async () => {
loadingPage.value = true
loadingPage.value = !catalog.loaded
try {
allProducts.value = await api.listProducts()
await catalog.load()
} catch (e) {
console.log(e)
} finally {
loadingPage.value = false
}
@@ -108,13 +108,14 @@ import Filters from '../../components/search/Filters.vue'
import SectionHead from '../../components/home/SectionHead.vue'
import ProductCard from '../../components/product/ProductCard.vue'
import { useFiltersStore } from '../../stores/filtersStore'
import { api, type ProductSummary } from '../../api/client'
import { useCatalogStore } from '../../stores/catalogStore'
const filters = useFiltersStore()
const catalog = useCatalogStore()
const loadingPage = ref(false)
const refreshing = ref(false)
const allProducts = ref<ProductSummary[]>([])
const allProducts = computed(() => catalog.products)
const showFilter = ref(false)
const filterKeys = ref<string[]>([])
@@ -187,17 +188,20 @@ watch(sentinel, mountObserver)
onBeforeUnmount(() => observer?.disconnect())
async function loadProducts() {
loadingPage.value = true
async function loadProducts(force = false) {
// Cached data renders at once; the spinner is only for a cold start.
loadingPage.value = !catalog.loaded
try {
allProducts.value = await api.listProducts()
await catalog.load(force)
} catch (e) {
console.log(e)
} finally {
loadingPage.value = false
}
}
async function onRefresh() {
await loadProducts()
await loadProducts(true)
refreshing.value = false
}
@@ -211,7 +215,7 @@ function showFilters() {
showFilter.value = true
}
onMounted(loadProducts)
onMounted(() => loadProducts())
</script>
<style scoped lang="less">