Skip to content

Commit 92993c0

Browse files
committed
fix: handle could not save
1 parent 290cff0 commit 92993c0

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/popup/App.vue

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
>
1616
<AppButton size="small" appearance="primary" outlined>Open</AppButton>
1717
</a>
18-
<AppButton v-else-if="isRootUrl && showcase && !showcase.isPublic" @click.native="saveShowcase" size="small" appearance="primary" class="mr-3">{{ saving ? 'Saving...' : 'Save' }}</AppButton>
18+
<AppButton v-else-if="isRootUrl && showcase && !showcase.isPublic && !savingError" @click.native="saveShowcase" size="small" appearance="primary" class="mr-3">{{ saving ? 'Saving...' : 'Save' }}</AppButton>
1919

2020
<a href="https://twitter.com/VueTelemetry" target="_blank" class="mr-3">
2121
<TwitterIcon class="w-5 h-5 hover:text-primary-500" />
@@ -40,6 +40,9 @@
4040
<div v-else-if="showcase">
4141
<div v-if="showcase.hasVue">
4242
<div class="mb-8">
43+
<div v-if="savingError" class="mb-4 text-orange">
44+
Could not save website to Vue Telemetry, please try again later or <a class="underline" :href="`mailto:[email protected]?subject=Could not save ${showcase.url}`">contact us</a>.
45+
</div>
4346
<div class="mb-4">
4447
<h3 class="flex items-center font-bold-body-weight pl-2 text-primary-500 uppercase">
4548
<InfoIcon class="h-5 mr-2 text-primary-5700 opacity-50" />Info
@@ -211,6 +214,7 @@ export default {
211214
return {
212215
isLoading: true,
213216
saving: false,
217+
savingError: false,
214218
showcase: null,
215219
currentTab: null
216220
}
@@ -289,18 +293,26 @@ export default {
289293
},
290294
async saveShowcase () {
291295
this.saving = true
292-
const res = await fetch(`https://vuetelemetry.com/api/analyze?url=${this.showcase.url}&isPublic=true&force=true`, {
293-
method: 'GET'
294-
})
295-
.then((response) => {
296-
this.saving = false
297-
return response.json()
296+
this.savingError = false
297+
try {
298+
await fetch(`https://vuetelemetry.com/api/analyze?url=${this.showcase.url}&isPublic=true&force=true`, {
299+
method: 'GET'
298300
})
299-
.catch((err) => {
300-
this.saving = false
301-
throw new Error(err)
302-
})
303-
this.showcase.isPublic = res.body.isPublic
301+
.then((response) => {
302+
if (!response.ok) {
303+
throw new Error('API call to VT failed')
304+
}
305+
return response.json()
306+
})
307+
.then(({ body }) => {
308+
this.showcase.slug = body.slug
309+
this.showcase.isPublic = body.isPublic
310+
this.saving = false
311+
})
312+
} catch (err) {
313+
this.saving = false
314+
this.savingError = true
315+
}
304316
}
305317
}
306318
}

tailwind.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ module.exports = {
6161
transparent: 'transparent',
6262
current: 'currentColor',
6363
white: 'white',
64+
orange: '#ed8936',
6465
primary: {
6566
50: '#E8FFF9',
6667
100: '#B7F8E7',

0 commit comments

Comments
 (0)