{"version":3,"file":"FetchCollectionsMixin-DcEv3N9Z.chunk.mjs","sources":["../src/mixins/FetchCollectionsMixin.ts"],"sourcesContent":["/**\n * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\n\nimport type { WebDAVClient } from 'webdav'\n\nimport { defineComponent } from 'vue'\nimport {\n\ttype Collection,\n\n\tfetchCollections,\n} from '../services/collectionFetcher.js'\nimport { davClient } from '../services/DavClient.ts'\nimport logger from '../services/logger.js'\nimport AbortControllerMixin from './AbortControllerMixin.js'\n\nexport default defineComponent({\n\tname: 'FetchCollectionsMixin',\n\n\tdata() {\n\t\treturn {\n\t\t\terrorFetchingCollections: null as null | number | Error | unknown,\n\t\t\tloadingCollections: false,\n\t\t}\n\t},\n\n\tmixins: [AbortControllerMixin],\n\n\tmethods: {\n\t\tasync fetchCollections(collectionHome: string, extraProps: string[] = [], client: WebDAVClient = davClient): Promise {\n\t\t\tif (this.loadingCollections) {\n\t\t\t\treturn []\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tthis.loadingCollections = true\n\t\t\t\tthis.errorFetchingCollections = null\n\n\t\t\t\tconst collections = await fetchCollections(collectionHome, { signal: this.abortController.signal }, extraProps, client)\n\n\t\t\t\tthis.$store.dispatch('addCollections', { collections })\n\n\t\t\t\treturn collections\n\t\t\t} catch (error) {\n\t\t\t\tif (error.response?.status === 404) {\n\t\t\t\t\tthis.errorFetchingCollections = 404\n\t\t\t\t} else {\n\t\t\t\t\tthis.errorFetchingCollections = error\n\t\t\t\t}\n\t\t\t\tlogger.error('Error fetching collections:', { error })\n\t\t\t} finally {\n\t\t\t\tthis.loadingCollections = false\n\t\t\t}\n\n\t\t\treturn []\n\t\t},\n\t},\n})\n"],"names":["FetchCollectionsMixin","defineComponent","AbortControllerMixin","collectionHome","extraProps","client","davClient","collections","fetchCollections","error","logger"],"mappings":"uOAiBA,MAAAA,EAAeC,EAAgB,CAC9B,KAAM,wBAEN,MAAO,CACN,MAAO,CACN,yBAA0B,KAC1B,mBAAoB,EAAA,CAEtB,EAEA,OAAQ,CAACC,CAAoB,EAE7B,QAAS,CACR,MAAM,iBAAiBC,EAAwBC,EAAuB,CAAA,EAAIC,EAAuBC,EAAkC,CAClI,GAAI,KAAK,mBACR,MAAO,CAAA,EAGR,GAAI,CACH,KAAK,mBAAqB,GAC1B,KAAK,yBAA2B,KAEhC,MAAMC,EAAc,MAAMC,EAAiBL,EAAgB,CAAE,OAAQ,KAAK,gBAAgB,QAAUC,EAAYC,CAAM,EAEtH,OAAA,KAAK,OAAO,SAAS,iBAAkB,CAAE,YAAAE,EAAa,EAE/CA,CACR,OAASE,EAAO,CACXA,EAAM,UAAU,SAAW,IAC9B,KAAK,yBAA2B,IAEhC,KAAK,yBAA2BA,EAEjCC,EAAO,MAAM,8BAA+B,CAAE,MAAAD,CAAA,CAAO,CACtD,QAAA,CACC,KAAK,mBAAqB,EAC3B,CAEA,MAAO,CAAA,CACR,CAAA,CAEF,CAAC"}