Skip to content

Commit

Permalink
dav: remove usage of path
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <radialapps@gmail.com>
  • Loading branch information
pulsejet committed Oct 18, 2023
1 parent 7e90fc8 commit 1ab738c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/services/dav/other.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getFiles } from './base';
import { generateUrl } from '@nextcloud/router';
import { IPhoto } from '../../types';
import { dirname } from 'path';
import { API } from '../API';

/**
* Open the files app with the given photo
Expand All @@ -21,13 +21,15 @@ export async function viewInFolder(photo: IPhoto) {
*/
export function viewInFolderUrl({ filename, fileid }: { filename: string; fileid: number }) {
// ensure dirPath starts with a slash
let dirPath = dirname(filename);
let dirPath = filename.substring(0, filename.lastIndexOf('/'));
if (!dirPath.startsWith('/')) {
dirPath = `/${dirPath}`;
}

return generateUrl(`/apps/files/?dir={dirPath}&scrollto={fileid}&openfile={fileid}`, {
fileid,
dirPath,
/** @todo Doesn't seem to work on Nextcloud 28 */
return API.Q(generateUrl('/apps/files/'), {
dir: dirPath,
scrollto: fileid,
openfile: fileid,
});
}

0 comments on commit 1ab738c

Please sign in to comment.