fix: only set initialized to true if artist/album list load is successful (#1629)

This commit is contained in:
Phan An 2022-12-15 21:09:44 +07:00 committed by GitHub
parent 9bb4e8c1f0
commit 66e1ee411c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View file

@ -29,7 +29,8 @@
<script lang="ts" setup>
import { computed, ref, toRef, watch } from 'vue'
import { albumStore, preferenceStore as preferences } from '@/stores'
import { useInfiniteScroll, useRouter } from '@/composables'
import { useInfiniteScroll, useMessageToaster, useRouter } from '@/composables'
import { logger } from '@/utils'
import AlbumCard from '@/components/album/AlbumCard.vue'
import AlbumCardSkeleton from '@/components/ui/skeletons/ArtistAlbumCardSkeleton.vue'
@ -68,7 +69,14 @@ useRouter().onScreenActivated('Albums', async () => {
if (!initialized) {
viewMode.value = preferences.albumsViewMode || 'thumbnails'
initialized = true
try {
await makeScrollable()
} catch (error) {
logger.error(error)
useMessageToaster().toastError('Failed to load albums.')
initialized = false
}
}
})
</script>

View file

@ -29,7 +29,8 @@
<script lang="ts" setup>
import { computed, ref, toRef, watch } from 'vue'
import { artistStore, preferenceStore as preferences } from '@/stores'
import { useInfiniteScroll, useRouter } from '@/composables'
import { useInfiniteScroll, useMessageToaster, useRouter } from '@/composables'
import { logger } from '@/utils'
import ArtistCard from '@/components/artist/ArtistCard.vue'
import ArtistCardSkeleton from '@/components/ui/skeletons/ArtistAlbumCardSkeleton.vue'
@ -68,7 +69,14 @@ useRouter().onScreenActivated('Artists', async () => {
if (!initialized) {
viewMode.value = preferences.artistsViewMode || 'thumbnails'
initialized = true
try {
await makeScrollable()
} catch (error) {
logger.error(error)
useMessageToaster().toastError('Failed to load artists.')
initialized = false
}
}
})
</script>