nx: attempt to share local file

Signed-off-by: Varun Patil <radialapps@gmail.com>
dexie
Varun Patil 2023-09-30 15:01:12 -07:00
parent 3ec3a7bcd2
commit e787b1c14e
2 changed files with 16 additions and 7 deletions

View File

@ -176,10 +176,18 @@ export default defineComponent({
}, },
async shareOriginal() { async shareOriginal() {
if (this.isLocal) { if (nativex.has()) {
return this.l(async () => await nativex.shareLocal(this.photo!.fileid)); 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() { async shareLink() {

View File

@ -77,10 +77,10 @@ export const API = {
/** /**
* Share a local file (as blob) with native page. * Share a local file (as blob) with native page.
* @regex ^/api/share/local/\d+$ * @regex ^/api/share/local/\d+$
* @param fileId File ID of the photo * @param auid AUID of the photo
* @returns {void} * @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. * Get list of local folders configuration.
@ -257,8 +257,9 @@ export async function shareBlobFromUrl(url: string) {
/** /**
* Share a local file with native page. * Share a local file with native page.
*/ */
export async function shareLocal(fileId: number) { export async function shareLocal(photo: IPhoto) {
await axios.get(API.SHARE_LOCAL(fileId)); if (!photo.auid) throw new Error('Cannot share local file without AUID');
await axios.get(API.SHARE_LOCAL(photo.auid));
} }
/** /**