Add separate loading and error states for currently building

Introduced `loadingCurrentlyBuilding` and `errorCurrentlyBuilding` states to manage the fetching of currently building packages independently. Updated the logic in `fetchCurrentlyBuilding` and related UI bindings to reflect this change, ensuring clearer state handling and improved error tracking.
This commit is contained in:
2025-05-04 23:57:45 +02:00
parent 35806589f0
commit 145de73133
2 changed files with 14 additions and 3 deletions

View File

@@ -103,7 +103,9 @@ const rtf = new Intl.RelativeTimeFormat('en', {
style: 'long'
})
const updateFailed = computed(() => !!packagesStore.state.error || !!statsStore.state.error)
const updateFailed = computed(
() => !!packagesStore.state.errorCurrentlyBuilding || !!statsStore.state.error
)
const lastMirrorSync = computed(
() =>
Math.floor(Date.now() / 1000) - (statsStore.state.stats?.last_mirror_timestamp || Date.now())

View File

@@ -17,7 +17,9 @@ export const usePackagesStore = defineStore('packages', () => {
offset: 0,
limit: Number(import.meta.env.VITE_LIMIT) || 50,
loading: false,
loadingCurrentlyBuilding: false,
error: null as string | null,
errorCurrentlyBuilding: null as string | null,
lastUpdated: Date.now(),
filters: {
status: undefined,
@@ -31,6 +33,8 @@ export const usePackagesStore = defineStore('packages', () => {
const fetchPackages = (init = false) => {
state.loading = true
state.error = null
state.packages = []
state.total = 0
if (init) {
initFromUrl()
@@ -76,10 +80,15 @@ export const usePackagesStore = defineStore('packages', () => {
})
.finally(() => {
state.loading = false
state.lastUpdated = Date.now()
})
}
const fetchCurrentlyBuilding = () => {
state.loadingCurrentlyBuilding = true
state.errorCurrentlyBuilding = null
state.currentlyBuildingPackages = []
getPackages({
limit: 0,
offset: 0,
@@ -92,13 +101,13 @@ export const usePackagesStore = defineStore('packages', () => {
if (err.statusCode === 404) {
state.currentlyBuildingPackages = []
} else {
state.error =
state.errorCurrentlyBuilding =
err instanceof Error ? err.message : 'Failed to fetch currently building packages'
console.error('Error fetching queued packages:', err)
}
})
.finally(() => {
state.loading = false
state.loadingCurrentlyBuilding = false
})
}