* Show error message in popular tab when instance does not support it (#3841)

This commit is contained in:
PikachuEXE 2023-08-03 22:44:30 +08:00 committed by GitHub
parent 8d9a1b8952
commit 51576a9563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import FtElementList from '../../components/ft-element-list/ft-element-list.vue'
import FtIconButton from '../../components/ft-icon-button/ft-icon-button.vue'
import { invidiousAPICall } from '../../helpers/api/invidious'
import { copyToClipboard, showToast } from '../../helpers/utils'
export default defineComponent({
name: 'Popular',
@ -28,7 +29,7 @@ export default defineComponent({
mounted: function () {
document.addEventListener('keydown', this.keyboardShortcutHandler)
this.shownResults = this.popularCache
this.shownResults = this.popularCache || []
if (!this.shownResults || this.shownResults.length < 1) {
this.fetchPopularInfo()
}
@ -47,7 +48,11 @@ export default defineComponent({
this.isLoading = true
const result = await invidiousAPICall(searchPayload)
.catch((err) => {
console.error(err)
const errorMessage = this.$t('Invidious API Error (Click to copy)')
showToast(`${errorMessage}: ${err}`, 10000, () => {
copyToClipboard(err)
})
return undefined
})
if (!result) {