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:
@@ -103,7 +103,9 @@ const rtf = new Intl.RelativeTimeFormat('en', {
|
|||||||
style: 'long'
|
style: 'long'
|
||||||
})
|
})
|
||||||
|
|
||||||
const updateFailed = computed(() => !!packagesStore.state.error || !!statsStore.state.error)
|
const updateFailed = computed(
|
||||||
|
() => !!packagesStore.state.errorCurrentlyBuilding || !!statsStore.state.error
|
||||||
|
)
|
||||||
const lastMirrorSync = computed(
|
const lastMirrorSync = computed(
|
||||||
() =>
|
() =>
|
||||||
Math.floor(Date.now() / 1000) - (statsStore.state.stats?.last_mirror_timestamp || Date.now())
|
Math.floor(Date.now() / 1000) - (statsStore.state.stats?.last_mirror_timestamp || Date.now())
|
||||||
|
@@ -17,7 +17,9 @@ export const usePackagesStore = defineStore('packages', () => {
|
|||||||
offset: 0,
|
offset: 0,
|
||||||
limit: Number(import.meta.env.VITE_LIMIT) || 50,
|
limit: Number(import.meta.env.VITE_LIMIT) || 50,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
loadingCurrentlyBuilding: false,
|
||||||
error: null as string | null,
|
error: null as string | null,
|
||||||
|
errorCurrentlyBuilding: null as string | null,
|
||||||
lastUpdated: Date.now(),
|
lastUpdated: Date.now(),
|
||||||
filters: {
|
filters: {
|
||||||
status: undefined,
|
status: undefined,
|
||||||
@@ -31,6 +33,8 @@ export const usePackagesStore = defineStore('packages', () => {
|
|||||||
const fetchPackages = (init = false) => {
|
const fetchPackages = (init = false) => {
|
||||||
state.loading = true
|
state.loading = true
|
||||||
state.error = null
|
state.error = null
|
||||||
|
state.packages = []
|
||||||
|
state.total = 0
|
||||||
|
|
||||||
if (init) {
|
if (init) {
|
||||||
initFromUrl()
|
initFromUrl()
|
||||||
@@ -76,10 +80,15 @@ export const usePackagesStore = defineStore('packages', () => {
|
|||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
state.loading = false
|
state.loading = false
|
||||||
|
state.lastUpdated = Date.now()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchCurrentlyBuilding = () => {
|
const fetchCurrentlyBuilding = () => {
|
||||||
|
state.loadingCurrentlyBuilding = true
|
||||||
|
state.errorCurrentlyBuilding = null
|
||||||
|
state.currentlyBuildingPackages = []
|
||||||
|
|
||||||
getPackages({
|
getPackages({
|
||||||
limit: 0,
|
limit: 0,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
@@ -92,13 +101,13 @@ export const usePackagesStore = defineStore('packages', () => {
|
|||||||
if (err.statusCode === 404) {
|
if (err.statusCode === 404) {
|
||||||
state.currentlyBuildingPackages = []
|
state.currentlyBuildingPackages = []
|
||||||
} else {
|
} else {
|
||||||
state.error =
|
state.errorCurrentlyBuilding =
|
||||||
err instanceof Error ? err.message : 'Failed to fetch currently building packages'
|
err instanceof Error ? err.message : 'Failed to fetch currently building packages'
|
||||||
console.error('Error fetching queued packages:', err)
|
console.error('Error fetching queued packages:', err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
state.loading = false
|
state.loadingCurrentlyBuilding = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user