viewer: reduce round trip for sidebar load

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/803/head
Varun Patil 2023-08-25 20:01:16 -07:00
parent ff481dffbb
commit 224bd3c2c9
2 changed files with 17 additions and 6 deletions

View File

@ -90,8 +90,8 @@ export default defineComponent({
}, },
methods: { methods: {
async open(photo: IPhoto | number, filename?: string, forceNative = false) { async open(photo: IPhoto | number, filename?: string, useNative = false) {
if (!this.reducedOpen && this.native && (!photo || forceNative)) { if (!this.reducedOpen && this.native && (!photo || useNative)) {
// Open native sidebar // Open native sidebar
this.native?.setFullScreenMode?.(true); this.native?.setFullScreenMode?.(true);
this.native?.open(filename); this.native?.open(filename);

View File

@ -1046,11 +1046,22 @@ export default defineComponent({
if (this.routeIsPublic || this.isLocal) { if (this.routeIsPublic || this.isLocal) {
globalThis.mSidebar.open(photo); globalThis.mSidebar.open(photo);
} else { } else {
const fileInfo = (await dav.getFiles([photo]))[0]; // check if file path is already loaded with image info
if (abort()) return; let filename = photo.imageInfo?.filename;
let useNative = !!filename;
const forceNative = fileInfo?.originalFilename?.startsWith('/files/'); // get filename from DAV if not already loaded
globalThis.mSidebar.open(photo, fileInfo?.filename, forceNative); if (!filename) {
const fileInfo = (await dav.getFiles([photo]))[0];
if (abort()) return;
// get filename
filename = fileInfo?.filename;
useNative = fileInfo?.originalFilename?.startsWith('/files/');
}
// open sidebar
globalThis.mSidebar.open(photo, filename, useNative);
} }
}; };