Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Fix count
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbo committed Oct 19, 2024
1 parent 2453b69 commit 6c3ed9a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
5 changes: 3 additions & 2 deletions components/ProfileView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const assets = computed(() => assetsData.value || [])
const isLoadingAssets = computed(() =>
assets.value.some(asset => asset.isLoading)
)
const { gridCount } = useGrid()
const { gridsForDisplay } = useGrid()
const filteredAssets = computed(() => {
return (
Expand Down Expand Up @@ -87,7 +87,8 @@ const tabs = computed<ProfileViewTab[]>(() => {
return [
{
id: 'grid',
count: gridCount.value > 1 ? gridCount.value : 0,
count:
gridsForDisplay.value.length > 1 ? gridsForDisplay.value.length : 0,
},
{
id: 'collectibles',
Expand Down
20 changes: 3 additions & 17 deletions domains/grid/components/GridTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,9 @@ type GridTab = {
const { selectedGridId, tempGrid, viewedGrid } = storeToRefs(useGridStore())
const { formatMessage } = useIntl()
const { showModal } = useModal()
const { canEditGrid } = useGrid()
const { canEditGrid, gridsForDisplay } = useGrid()
const tabs = ref<GridTab[]>([])
const grid = computed(() => {
if (canEditGrid.value) {
return tempGrid.value
}
return viewedGrid.value
})
// we only show tabs when user has more then one
const hasTabs = computed(() => tabs.value.length > 1)
Expand All @@ -42,15 +34,9 @@ const checkMove = (event: any) => {
watch(
[canEditGrid, tempGrid, viewedGrid],
() => {
tabs.value = grid.value
.filter(grid => grid.grid.length > 0)
.map(grid => {
return {
grid,
}
})
tabs.value = gridsForDisplay.value
},
{ immediate: true }
{ immediate: true, deep: true }
)
</script>

Expand Down
18 changes: 11 additions & 7 deletions domains/grid/composables/useGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ export const useGrid = () => {
}
}

const gridCount = computed(() => {
if (canEditGrid.value) {
return tempGrid.value.length
}

return viewedGrid.value.length
const gridsForDisplay = computed(() => {
const grids = canEditGrid.value
? tempGrid.value
: viewedGrid.value.filter(grid => grid.grid.length > 0)

return grids.map(grid => {
return {
grid,
}
})
})

return {
Expand Down Expand Up @@ -288,6 +292,6 @@ export const useGrid = () => {
canEditGrid,
initSelectedGridId,
getGridById,
gridCount,
gridsForDisplay,
}
}

0 comments on commit 6c3ed9a

Please sign in to comment.