feat: catalog read cache (api + user apps) and clearer Zarrin accounting errors
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user