diff options
author | Azul <azul@riseup.net> | 2020-07-08 16:58:04 +0300 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2020-08-11 11:34:49 +0300 |
commit | c5fedf4499261a9119c7427ab825deeb1c423875 (patch) | |
tree | 1e41a47d94ddb2d1f5028d2e82f57e2b7505fd42 /src | |
parent | bf7f4406c7792a09f8cc31d298ca3d3abd0c22f6 (diff) |
fix: use OC.Files API to get file info
This api is also available in other apps while
the internal structures used in fetchFileInfo are not.
fixes #920
Signed-off-by: Azul <azul@riseup.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/MenuBar.vue | 5 | ||||
-rw-r--r-- | src/helpers/files.js | 44 |
2 files changed, 2 insertions, 47 deletions
diff --git a/src/components/MenuBar.vue b/src/components/MenuBar.vue index 21930ba12..3fe9a2380 100644 --- a/src/components/MenuBar.vue +++ b/src/components/MenuBar.vue @@ -75,7 +75,6 @@ import { EditorMenuBar } from 'tiptap' import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip' import menuBarIcons from './../mixins/menubar' -import { fetchFileInfo } from './../helpers/files' import Actions from '@nextcloud/vue/dist/Components/Actions' import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' @@ -245,8 +244,8 @@ export default { } const _command = command OC.dialogs.filepicker('Insert an image', (file) => { - fetchFileInfo(currentUser.uid, file).then((info) => { - const fileInfo = info[0] + const client = OC.Files.getClient() + client.getFileInfo(file).then((_status, fileInfo) => { this.lastImagePath = fileInfo.path // dirty but works so we have the information stored in markdown diff --git a/src/helpers/files.js b/src/helpers/files.js index 76d27617b..5cd228ff0 100644 --- a/src/helpers/files.js +++ b/src/helpers/files.js @@ -24,54 +24,11 @@ * Callback that should be executed after the document is ready * @param callback */ -import axios from '@nextcloud/axios' -import { generateRemoteUrl } from '@nextcloud/router' import { openMimetypes } from './mime' import RichWorkspace from '../views/RichWorkspace' const FILE_ACTION_IDENTIFIER = 'Edit with text app' -const fetchFileInfo = async function(user, path) { - const response = await axios({ - method: 'PROPFIND', - url: generateRemoteUrl(`dav/files/${user}${path}`), - headers: { - requesttoken: OC.requestToken, - 'content-Type': 'text/xml', - }, - data: `<?xml version="1.0"?> -<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns" xmlns:ocs="http://open-collaboration-services.org/ns"> - <d:prop> - <d:getlastmodified /> - <d:getetag /> - <d:getcontenttype /> - <d:resourcetype /> - <oc:fileid /> - <oc:permissions /> - <oc:size /> - <d:getcontentlength /> - <nc:has-preview /> - <nc:mount-type /> - <nc:is-encrypted /> - <ocs:share-permissions /> - <oc:tags /> - <oc:favorite /> - <oc:comments-unread /> - <oc:owner-id /> - <oc:owner-display-name /> - <oc:share-types /> - </d:prop> -</d:propfind>`, - }) - - const files = OCA.Files.App.fileList.filesClient._client.parseMultiStatus(response.data) - return files.map(file => { - const fileInfo = OCA.Files.App.fileList.filesClient._parseFileInfo(file) - fileInfo.href = file.href - return fileInfo - }) -} - const registerFileCreate = () => { const newFileMenuPlugin = { attach: function(menu) { @@ -199,7 +156,6 @@ const FilesWorkspacePlugin = { } export { - fetchFileInfo, registerFileActionFallback, registerFileCreate, FilesWorkspacePlugin, |