nx: attempt to share local file
Signed-off-by: Varun Patil <radialapps@gmail.com>dexie
parent
3ec3a7bcd2
commit
e787b1c14e
|
@ -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() {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue