Skip to content

Commit b3d0763

Browse files
committed
docs(commits): handle failing more gracefully
1 parent 8fc2e9f commit b3d0763

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

packages/docs/src/components/app/settings/LatestCommit.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
22
<AppListLinkListItem
3-
v-if="commits.latest"
4-
:href="`https://github.com/vuetifyjs/vuetify/commit/${commits.latest?.sha}`"
3+
v-if="commits.latest?.sha"
4+
:href="`https://github.com/vuetifyjs/vuetify/commit/${commits.latest.sha}`"
55
:label="t('latest-commit')"
6-
:title="commits.latest?.sha.slice(0, 7)"
6+
:title="commits.latest.sha.slice(0, 7)"
77
append-icon="mdi-open-in-new"
88
min-width="90"
99
prepend-icon="mdi-source-commit"

packages/docs/src/stores/commits.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ export const useCommitsStore = defineStore('commits', {
2121
this.isLoading = true
2222

2323
try {
24-
this.commits = await fetch(`${url}/github/commits`, {
24+
const res = await fetch(`${url}/github/commits`, {
2525
method: 'GET',
2626
credentials: 'include',
27-
}).then(res => res.json())
27+
}).then(async res => res.json())
28+
29+
this.commits = res
2830
} catch (err: any) {
29-
console.error(err)
31+
console.warn(`Failed to fetch commits: ${err.message}`)
3032
}
3133

3234
this.isLoading = false
@@ -35,7 +37,7 @@ export const useCommitsStore = defineStore('commits', {
3537

3638
getters: {
3739
latest (state) {
38-
return state.commits[0]
40+
return state.commits?.[0]
3941
},
4042
},
4143
})

0 commit comments

Comments
 (0)