Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/photos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2022-09-20 17:11:57 +0300
committerGitHub <noreply@github.com>2022-09-20 17:11:57 +0300
commit51725d2ee5d5a358f3eeaab51fb2660213a8f2ea (patch)
tree19c58403b7ba19a76dc023c90f5e4c329989a458 /src
parentf86e902b55c7d174c2d1dcea33c3fccd6f0da77b (diff)
parent775aec519de595c51328db8216c231f3f8fd203e (diff)
Merge pull request #1267 from nextcloud/fix/source
Make sure we have a valid source for each file
Diffstat (limited to 'src')
-rw-r--r--src/components/File.vue9
-rw-r--r--src/components/FileLegacy.vue8
-rw-r--r--src/services/DavClient.js4
-rw-r--r--src/services/PhotoSearch.js3
-rw-r--r--src/utils/fileUtils.js13
-rw-r--r--src/views/AlbumContent.vue3
-rw-r--r--src/views/SharedAlbumContent.vue3
7 files changed, 18 insertions, 25 deletions
diff --git a/src/components/File.vue b/src/components/File.vue
index a7901e4c..455b4668 100644
--- a/src/components/File.vue
+++ b/src/components/File.vue
@@ -25,7 +25,7 @@
data-test="media"
:class="{selected}">
<a class="file"
- :href="davPath"
+ :href="file.source"
:aria-label="ariaLabel"
@click.stop.prevent="emitClick">
@@ -71,8 +71,7 @@
import Star from 'vue-material-design-icons/Star'
import VideoIcon from 'vue-material-design-icons/Video.vue'
-import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
-import { getCurrentUser } from '@nextcloud/auth'
+import { generateUrl } from '@nextcloud/router'
import { NcCheckboxRadioSwitch } from '@nextcloud/vue'
import UserConfig from '../mixins/UserConfig.js'
@@ -122,10 +121,6 @@ export default {
computed: {
/** @return {string} */
- davPath() {
- return generateRemoteUrl(`dav/files/${getCurrentUser().uid}`) + this.file.filename
- },
- /** @return {string} */
ariaDescription() {
return `image-description-${this.file.fileid}`
},
diff --git a/src/components/FileLegacy.vue b/src/components/FileLegacy.vue
index 7e0a152d..16ea8aa2 100644
--- a/src/components/FileLegacy.vue
+++ b/src/components/FileLegacy.vue
@@ -25,7 +25,7 @@
'file--cropped': croppedLayout,
}"
class="file"
- :href="davPath"
+ :href="item.injected.source"
:aria-label="ariaLabel"
@click.prevent="openViewer">
<div v-if="item.injected.mime.includes('video') && item.injected.hasPreview" class="icon-video-white" />
@@ -57,8 +57,7 @@
</template>
<script>
-import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
-import { getCurrentUser } from '@nextcloud/auth'
+import { generateUrl } from '@nextcloud/router'
import UserConfig from '../mixins/UserConfig.js'
@@ -81,9 +80,6 @@ export default {
},
computed: {
- davPath() {
- return generateRemoteUrl(`dav/files/${getCurrentUser().uid}`) + this.item.injected.filename
- },
ariaUuid() {
return `image-${this.item.injected.fileid}`
},
diff --git a/src/services/DavClient.js b/src/services/DavClient.js
index f1ab7c72..2d4da082 100644
--- a/src/services/DavClient.js
+++ b/src/services/DavClient.js
@@ -25,12 +25,14 @@ import axios from '@nextcloud/axios'
import parseUrl from 'url-parse'
import { generateRemoteUrl } from '@nextcloud/router'
+export const rootPath = 'dav'
+
// force our axios
const patcher = getPatcher()
patcher.patch('request', axios)
// init webdav client on default dav endpoint
-const remote = generateRemoteUrl('dav')
+const remote = generateRemoteUrl(rootPath)
const client = createClient(remote)
export const remotePath = parseUrl(remote).pathname
diff --git a/src/services/PhotoSearch.js b/src/services/PhotoSearch.js
index 06836f9b..62e997f4 100644
--- a/src/services/PhotoSearch.js
+++ b/src/services/PhotoSearch.js
@@ -26,7 +26,6 @@ import { allMimes } from './AllowedMimes.js'
import client from './DavClient.js'
import { props } from './DavRequest.js'
import moment from '@nextcloud/moment'
-import { generateRemoteUrl } from '@nextcloud/router'
/**
* List files from a folder and filter out unwanted mimes
@@ -147,6 +146,4 @@ export default async function(path = '', options = {}) {
const response = await client.getDirectoryContents('', options)
return response.data.map(data => genFileInfo(data))
- .map(file => ({ ...file, source: generateRemoteUrl(`dav${file.filename}`) }))
-
}
diff --git a/src/utils/fileUtils.js b/src/utils/fileUtils.js
index 9d3c522b..2e9fd1d6 100644
--- a/src/utils/fileUtils.js
+++ b/src/utils/fileUtils.js
@@ -19,8 +19,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+import { generateRemoteUrl } from '@nextcloud/router'
import camelcase from 'camelcase'
-import { isNumber } from './numberUtils'
+import { rootPath } from '../services/DavClient.js'
+import { isNumber } from './numberUtils.js'
/**
* Get an url encoded path
@@ -101,7 +103,7 @@ const sortCompare = function(fileInfo1, fileInfo2, key, asc = true) {
* @param {object} obj - object to flatten and format.
*/
function genFileInfo(obj) {
- return Object.entries(obj).reduce((fileInfo, [key, data]) => {
+ const fileInfo = Object.entries(obj).reduce((fileInfo, [key, data]) => {
// flatten object if any
if (!!data && typeof data === 'object' && !Array.isArray(data)) {
return { ...fileInfo, ...genFileInfo(data) }
@@ -117,6 +119,13 @@ function genFileInfo(obj) {
return { ...fileInfo, [camelcase(key)]: isNumber(data) ? Number(data) : data }
}
}, {})
+
+ if (fileInfo.filename) {
+ // Adding context
+ fileInfo.source = generateRemoteUrl(rootPath) + '/' + fileInfo.filename
+ }
+
+ return fileInfo
}
export { encodeFilePath, extractFilePaths, sortCompare, genFileInfo }
diff --git a/src/views/AlbumContent.vue b/src/views/AlbumContent.vue
index e1836d8c..ca3df6ee 100644
--- a/src/views/AlbumContent.vue
+++ b/src/views/AlbumContent.vue
@@ -154,7 +154,6 @@
<script>
// eslint-disable-next-line node/no-extraneous-import
import { addNewFileMenuEntry } from '@nextcloud/files'
-import { generateRemoteUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { mapActions, mapGetters } from 'vuex'
import { NcActions, NcActionButton, NcButton, NcModal, NcEmptyContent, NcActionSeparator, NcLoadingIcon, isMobile } from '@nextcloud/vue'
@@ -340,8 +339,6 @@ export default {
const fetchedFiles = response.data
.map(file => genFileInfo(file))
- // For the Viewer.
- .map(file => ({ ...file, source: generateRemoteUrl(`dav${file.filename}`) }))
const fileIds = fetchedFiles
.map(file => file.fileid)
diff --git a/src/views/SharedAlbumContent.vue b/src/views/SharedAlbumContent.vue
index fe6a65f8..dde0656e 100644
--- a/src/views/SharedAlbumContent.vue
+++ b/src/views/SharedAlbumContent.vue
@@ -125,7 +125,6 @@ import Close from 'vue-material-design-icons/Close'
import { NcActions, NcActionButton, NcButton, NcModal, NcEmptyContent, NcActionSeparator, isMobile } from '@nextcloud/vue'
import { getCurrentUser } from '@nextcloud/auth'
-import { generateRemoteUrl } from '@nextcloud/router'
import FetchSharedAlbumsMixin from '../mixins/FetchSharedAlbumsMixin.js'
import FetchFilesMixin from '../mixins/FetchFilesMixin.js'
@@ -242,8 +241,6 @@ export default {
const fetchedFiles = response.data
.map(file => genFileInfo(file))
- // For the Viewer.
- .map(file => ({ ...file, source: generateRemoteUrl(`dav${file.filename}`) }))
const fileIds = fetchedFiles
.map(file => file.fileid)