1 line
5.2 KiB
Plaintext
1 line
5.2 KiB
Plaintext
{"version":3,"file":"FetchCollectionContentMixin-BXizDLoQ.chunk.mjs","sources":["../src/mixins/FetchCollectionContentMixin.ts"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { File } from '@nextcloud/files'\nimport type { WebDAVClient } from 'webdav'\n\nimport { showError } from '@nextcloud/dialogs'\nimport { t } from '@nextcloud/l10n'\nimport { defineComponent } from 'vue'\nimport {\n\ttype Collection,\n\n\tfetchCollection, fetchCollectionFiles,\n} from '../services/collectionFetcher.js'\nimport logger from '../services/logger.js'\nimport { collectionFilesExtraProps } from '../store/collections.js'\nimport SemaphoreWithPriority from '../utils/semaphoreWithPriority.js'\nimport AbortControllerMixin from './AbortControllerMixin.js'\n\nexport default defineComponent({\n\tname: 'FetchCollectionContentMixin',\n\n\tdata() {\n\t\treturn {\n\t\t\tfetchSemaphore: new SemaphoreWithPriority(1),\n\t\t\tloadingCollection: false,\n\t\t\tloadingCollectionFiles: false,\n\t\t\terrorFetchingCollection: null as null | number | Error | unknown,\n\t\t\terrorFetchingCollectionFiles: null as null | number | Error | unknown,\n\t\t}\n\t},\n\n\tmixins: [AbortControllerMixin],\n\n\tmethods: {\n\t\tasync fetchCollection(collectionFileName: string, extraProps: string[], client?: WebDAVClient): Promise<Collection | null> {\n\t\t\tif (this.loadingCollection) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tthis.loadingCollection = true\n\t\t\t\tthis.errorFetchingCollection = null\n\n\t\t\t\tconst collection = await fetchCollection(collectionFileName, { signal: this.abortController.signal }, extraProps, client)\n\t\t\t\tthis.$store.dispatch('addCollections', { collections: [collection] })\n\t\t\t\treturn collection\n\t\t\t} catch (error) {\n\t\t\t\tif (error.response?.status === 404) {\n\t\t\t\t\tthis.errorFetchingCollection = 404\n\t\t\t\t\treturn null\n\t\t\t\t}\n\n\t\t\t\tthis.errorFetchingCollection = error\n\t\t\t\tlogger.error('[PublicCollectionContent] Error fetching collection', { error })\n\t\t\t\tshowError(t('photos', 'Failed to fetch collection.'))\n\t\t\t} finally {\n\t\t\t\tthis.loadingCollection = false\n\t\t\t}\n\n\t\t\treturn null\n\t\t},\n\n\t\tasync fetchCollectionFiles(collectionFileName: string, extraProps: string[] = [], client?: WebDAVClient): Promise<File[]> {\n\t\t\tif (this.loadingCollectionFiles) {\n\t\t\t\treturn []\n\t\t\t}\n\n\t\t\textraProps = [...extraProps, ...collectionFilesExtraProps]\n\n\t\t\tconst fetchSemaphoreSymbol = await this.fetchSemaphore.acquire()\n\n\t\t\ttry {\n\t\t\t\tthis.errorFetchingCollectionFiles = null\n\t\t\t\tthis.loadingCollectionFiles = true\n\n\t\t\t\tconst fetchedFiles = await fetchCollectionFiles(collectionFileName, { signal: this.abortController.signal }, extraProps, client)\n\t\t\t\tconst fileIds = fetchedFiles.map((file) => file.fileid?.toString())\n\n\t\t\t\tthis.$store.dispatch('appendFiles', fetchedFiles)\n\n\t\t\t\tawait this.$store.commit('setCollectionFiles', { collectionFileName, fileIds })\n\n\t\t\t\treturn fetchedFiles\n\t\t\t} catch (error) {\n\t\t\t\tif (error.response?.status === 404) {\n\t\t\t\t\tthis.errorFetchingCollectionFiles = 404\n\t\t\t\t\treturn []\n\t\t\t\t}\n\n\t\t\t\tthis.errorFetchingCollectionFiles = error\n\n\t\t\t\tshowError(t('photos', 'Failed to fetch collections list.'))\n\t\t\t\tlogger.error('[PublicCollectionContent] Error fetching collection files', { error })\n\t\t\t} finally {\n\t\t\t\tthis.loadingCollectionFiles = false\n\t\t\t\tthis.fetchSemaphore.release(fetchSemaphoreSymbol)\n\t\t\t}\n\n\t\t\treturn []\n\t\t},\n\t},\n})\n"],"names":["FetchCollectionContentMixin","defineComponent","SemaphoreWithPriority","AbortControllerMixin","collectionFileName","extraProps","client","collection","fetchCollection","error","logger","showError","t","collectionFilesExtraPro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