diff --git a/src/components/modal/ShareModal.vue b/src/components/modal/ShareModal.vue index f8a08efd..64b4389c 100644 --- a/src/components/modal/ShareModal.vue +++ b/src/components/modal/ShareModal.vue @@ -176,10 +176,18 @@ export default defineComponent({ }, async shareOriginal() { - if (this.isLocal) { - return this.l(async () => await nativex.shareLocal(this.photo!.fileid)); + if (nativex.has()) { + try { + return await this.l(async () => await nativex.shareLocal(this.photo!)); + } catch (e) { + // maybe the file doesn't exist locally + } + + // if it's purel local, we can't share it + if (this.isLocal) return; } - this.shareWithHref(dav.getDownloadLink(this.photo!)); + + await this.shareWithHref(dav.getDownloadLink(this.photo!)); }, async shareLink() { diff --git a/src/native.ts b/src/native.ts index 7f58a0f9..cf5a3173 100644 --- a/src/native.ts +++ b/src/native.ts @@ -77,10 +77,10 @@ export const API = { /** * Share a local file (as blob) with native page. * @regex ^/api/share/local/\d+$ - * @param fileId File ID of the photo + * @param auid AUID of the photo * @returns {void} */ - SHARE_LOCAL: (fileId: number) => `${BASE_URL}/api/share/local/${fileId}`, + SHARE_LOCAL: (auid: number) => `${BASE_URL}/api/share/local/${auid}`, /** * Get list of local folders configuration. @@ -257,8 +257,9 @@ export async function shareBlobFromUrl(url: string) { /** * Share a local file with native page. */ -export async function shareLocal(fileId: number) { - await axios.get(API.SHARE_LOCAL(fileId)); +export async function shareLocal(photo: IPhoto) { + if (!photo.auid) throw new Error('Cannot share local file without AUID'); + await axios.get(API.SHARE_LOCAL(photo.auid)); } /**