dav: remove dead code

Signed-off-by: Varun Patil <radialapps@gmail.com>
dexie
Varun Patil 2023-09-29 20:46:26 -07:00
parent a1072d03b5
commit 248a3cd7a0
4 changed files with 10 additions and 161 deletions

17
package-lock.json generated
View File

@ -13,7 +13,6 @@
"@nextcloud/paths": "^2.1.0", "@nextcloud/paths": "^2.1.0",
"@nextcloud/sharing": "^0.1.0", "@nextcloud/sharing": "^0.1.0",
"@nextcloud/vue": "7.12.1", "@nextcloud/vue": "7.12.1",
"camelcase": "^7.0.1",
"filerobot-image-editor": "^4.5.1", "filerobot-image-editor": "^4.5.1",
"fuse.js": "^6.6.2", "fuse.js": "^6.6.2",
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
@ -3836,17 +3835,6 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/camelcase": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-7.0.1.tgz",
"integrity": "sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==",
"engines": {
"node": ">=14.16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/camelize": { "node_modules/camelize": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz", "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz",
@ -14485,11 +14473,6 @@
"get-intrinsic": "^1.0.2" "get-intrinsic": "^1.0.2"
} }
}, },
"camelcase": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-7.0.1.tgz",
"integrity": "sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw=="
},
"camelize": { "camelize": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz", "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz",

View File

@ -34,7 +34,6 @@
"@nextcloud/paths": "^2.1.0", "@nextcloud/paths": "^2.1.0",
"@nextcloud/sharing": "^0.1.0", "@nextcloud/sharing": "^0.1.0",
"@nextcloud/vue": "7.12.1", "@nextcloud/vue": "7.12.1",
"camelcase": "^7.0.1",
"filerobot-image-editor": "^4.5.1", "filerobot-image-editor": "^4.5.1",
"fuse.js": "^6.6.2", "fuse.js": "^6.6.2",
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",

View File

@ -3,24 +3,12 @@ import { translate as t } from '@nextcloud/l10n';
import axios from '@nextcloud/axios'; import axios from '@nextcloud/axios';
import { IFileInfo, IPhoto } from '../../types'; import { IFileInfo, IPhoto } from '../../types';
import { genFileInfo } from '../file-utils';
import { API } from '../API'; import { API } from '../API';
import { getAlbumFileInfos } from './albums'; import { getAlbumFileInfos } from './albums';
import client from './client'; import client from './client';
import * as utils from '../utils'; import * as utils from '../utils';
import * as nativex from '../../native'; import * as nativex from '../../native';
export const props = `
<oc:fileid />
<oc:permissions />
<d:getlastmodified />
<d:getetag />
<d:getcontenttype />
<d:getcontentlength />
<nc:has-preview />
<oc:favorite />
<d:resourcetype />`;
const GET_FILE_CHUNK_SIZE = 50; const GET_FILE_CHUNK_SIZE = 50;
type GetFilesOpts = { type GetFilesOpts = {
@ -127,7 +115,7 @@ async function getFilesInternal2(fileIds: number[]): Promise<IFileInfo[]> {
<d:basicsearch> <d:basicsearch>
<d:select> <d:select>
<d:prop> <d:prop>
${props} <oc:fileid />
</d:prop> </d:prop>
</d:select> </d:select>
<d:from> <d:from>
@ -148,15 +136,15 @@ async function getFilesInternal2(fileIds: number[]): Promise<IFileInfo[]> {
responseType: 'text', responseType: 'text',
}; };
let response: any = await client.getDirectoryContents('', options); const response: any = await client.getDirectoryContents('', options);
return response.data
.map((data: any) => genFileInfo(data)) return response.data.map((data: any) => ({
.map((data: any) => id: data.props.fileid,
Object.assign({}, data, { fileid: data.props.fileid,
originalFilename: data.filename, basename: data.basename,
filename: data.filename.replace(prefixPath, ''), originalFilename: data.filename,
}) filename: data.filename.replace(prefixPath, ''),
); }));
} }
/** /**

View File

@ -1,121 +0,0 @@
/**
* @copyright Copyright (c) 2019 John Molakvoæ <skjnldsv@protonmail.com>
*
* @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @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 camelcase from 'camelcase';
import { isNumber } from './utils/algo';
import { getLanguage } from '@nextcloud/l10n';
/**
* Get an url encoded path
*
* @param {string} path the full path
* @return {string} url encoded file path
*/
const encodeFilePath = function (path) {
const pathSections = (path.startsWith('/') ? path : `/${path}`).split('/');
let relativePath = '';
pathSections.forEach((section) => {
if (section !== '') {
relativePath += '/' + encodeURIComponent(section);
}
});
return relativePath;
};
/**
* Extract dir and name from file path
*
* @param {string} path the full path
* @return {string[]} [dirPath, fileName]
*/
const extractFilePaths = function (path) {
const pathSections = path.split('/');
const fileName = pathSections[pathSections.length - 1];
const dirPath = pathSections.slice(0, pathSections.length - 1).join('/');
return [dirPath, fileName];
};
/**
* Sorting comparison function
*
* @param {object} fileInfo1 file 1 fileinfo
* @param {object} fileInfo2 file 2 fileinfo
* @param {string} key key to sort with
* @param {boolean} [asc=true] sort ascending?
* @return {number}
*/
const sortCompare = function (fileInfo1, fileInfo2, key, asc = true) {
// favorite always first
if (fileInfo1.isFavorite && !fileInfo2.isFavorite) {
return -1;
} else if (!fileInfo1.isFavorite && fileInfo2.isFavorite) {
return 1;
}
// if this is a number, let's sort by integer
if (isNumber(fileInfo1[key]) && isNumber(fileInfo2[key])) {
return asc ? Number(fileInfo2[key]) - Number(fileInfo1[key]) : Number(fileInfo1[key]) - Number(fileInfo2[key]);
}
// else we sort by string, so let's sort directories first
if (fileInfo1.type !== 'file' && fileInfo2.type === 'file') {
return asc ? -1 : 1;
} else if (fileInfo1.type === 'file' && fileInfo2.type !== 'file') {
return asc ? 1 : -1;
}
// if this is a date, let's sort by date
if (isNumber(new Date(fileInfo1[key]).getTime()) && isNumber(new Date(fileInfo2[key]).getTime())) {
return asc
? new Date(fileInfo2[key]).getTime() - new Date(fileInfo1[key]).getTime()
: new Date(fileInfo1[key]).getTime() - new Date(fileInfo2[key]).getTime();
}
// finally sort by name
return asc
? fileInfo1[key]?.toString()?.localeCompare(fileInfo2[key].toString(), getLanguage()) || 1
: -fileInfo1[key]?.toString()?.localeCompare(fileInfo2[key].toString(), getLanguage()) || -1;
};
const genFileInfo = function (obj) {
const fileInfo = {};
Object.keys(obj).forEach((key) => {
const data = obj[key];
// flatten object if any
if (!!data && typeof data === 'object') {
Object.assign(fileInfo, genFileInfo(data));
} else {
// format key and add it to the fileInfo
if (data === 'false') {
fileInfo[camelcase(key)] = false;
} else if (data === 'true') {
fileInfo[camelcase(key)] = true;
} else {
fileInfo[camelcase(key)] = isNumber(data) ? Number(data) : data;
}
}
});
return fileInfo;
};
export { encodeFilePath, extractFilePaths, sortCompare, genFileInfo };