mirror of
https://github.com/immich-app/immich.git
synced 2025-02-04 01:09:14 -05:00
feat(web) using template filename for downloaded file (#1164)
* feat(web) using template filename for downloaded file * remove deadcode
This commit is contained in:
parent
443182c879
commit
f25809befb
1 changed files with 16 additions and 2 deletions
|
@ -21,6 +21,7 @@
|
||||||
notificationController,
|
notificationController,
|
||||||
NotificationType
|
NotificationType
|
||||||
} from '../shared-components/notification/notification';
|
} from '../shared-components/notification/notification';
|
||||||
|
|
||||||
import { assetStore } from '$lib/stores/assets.store';
|
import { assetStore } from '$lib/stores/assets.store';
|
||||||
|
|
||||||
export let asset: AssetResponseDto;
|
export let asset: AssetResponseDto;
|
||||||
|
@ -98,11 +99,24 @@
|
||||||
downloadFile(asset.id, false);
|
downloadFile(asset.id, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the filename of the asset based on the user defined template
|
||||||
|
*/
|
||||||
|
const getTemplateFilename = () => {
|
||||||
|
const filenameWithExtension = asset.originalPath.split('/').pop() as string;
|
||||||
|
const filenameWithoutExtension = filenameWithExtension.split('.')[0];
|
||||||
|
return {
|
||||||
|
filenameWithExtension,
|
||||||
|
filenameWithoutExtension
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const downloadFile = async (assetId: string, isLivePhoto: boolean) => {
|
const downloadFile = async (assetId: string, isLivePhoto: boolean) => {
|
||||||
try {
|
try {
|
||||||
const imageName = asset.exifInfo?.imageName ? asset.exifInfo?.imageName : asset.id;
|
const { filenameWithoutExtension } = getTemplateFilename();
|
||||||
|
|
||||||
const imageExtension = isLivePhoto ? 'mov' : asset.originalPath.split('.')[1];
|
const imageExtension = isLivePhoto ? 'mov' : asset.originalPath.split('.')[1];
|
||||||
const imageFileName = imageName + '.' + imageExtension;
|
const imageFileName = filenameWithoutExtension + '.' + imageExtension;
|
||||||
|
|
||||||
// If assets is already download -> return;
|
// If assets is already download -> return;
|
||||||
if ($downloadAssets[imageFileName]) {
|
if ($downloadAssets[imageFileName]) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue