-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve overall preview loading #1647
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,25 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
/** | ||
* @copyright Copyright (c) 2023 Louis Chemineau <[email protected]> | ||
* | ||
* @author Louis Chemineau <[email protected]> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* @copyright Copyright (c) 2023 Louis Chemineau <[email protected]> | ||
* | ||
* @author Louis Chemineau <[email protected]> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
import { genFileInfo } from '../utils/fileUtils.js' | ||
import defaultClient from './DavClient.js' | ||
|
||
/** | ||
* @param {string[]} extraProps - Extra properties to add to the DAV request. | ||
* @return {string} | ||
*/ | ||
function getCollectionFilesDavRequest(extraProps = []) { | ||
return `<?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:getcontentlength /> | ||
<d:getcontenttype /> | ||
<d:getetag /> | ||
<d:getlastmodified /> | ||
<d:resourcetype /> | ||
<nc:file-metadata-size /> | ||
<nc:has-preview /> | ||
<oc:favorite /> | ||
<oc:fileid /> | ||
<oc:permissions /> | ||
${extraProps.join('')} | ||
</d:prop> | ||
</d:propfind>` | ||
} | ||
|
||
/** | ||
* @param {string} fileName - The full file's name | ||
* @param {import('webdav').StatOptions} options - Options to forward to the webdav client. | ||
* @return {Promise<object>} | ||
*/ | ||
export async function fetchFile(fileName, options = {}) { | ||
try { | ||
const response = await defaultClient.stat(fileName, { | ||
data: getCollectionFilesDavRequest(), | ||
details: true, | ||
...options, | ||
}) | ||
|
||
return genFileInfo(response.data) | ||
} catch (error) { | ||
if (error.code === 'ERR_CANCELED') { | ||
return null | ||
} | ||
|
||
throw error | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was making the editor to emit the wrong event as there was a duplicate
//
https://github.com/nextcloud/viewer/blob/0931d2e08f630fe0748e807db427f8933cca3dbc/src/components/ImageEditor.vue#L174