remove console.logs, add svelte binding
This commit is contained in:
@@ -13,40 +13,32 @@
|
|||||||
import type { UserResponseDto } from '@api';
|
import type { UserResponseDto } from '@api';
|
||||||
import { notificationController, NotificationType } from './notification/notification';
|
import { notificationController, NotificationType } from './notification/notification';
|
||||||
import { lastUpdatedProfilePicture } from '$lib/stores/preferences.store';
|
import { lastUpdatedProfilePicture } from '$lib/stores/preferences.store';
|
||||||
onMount(() => {
|
|
||||||
console.log(asset);
|
|
||||||
});
|
|
||||||
|
|
||||||
let user: UserResponseDto;
|
let user: UserResponseDto;
|
||||||
|
let profilePicture: HTMLDivElement;
|
||||||
|
|
||||||
const handleSetProfilePicture = async () => {
|
const handleSetProfilePicture = async () => {
|
||||||
const div: HTMLElement | null = document.getElementById('profile-picture')?.childNodes[0] as HTMLElement;
|
const div = profilePicture.childNodes[0] as HTMLDivElement;
|
||||||
if (!div) {
|
const blob: Blob = await domtoimage.toBlob(div);
|
||||||
return;
|
const file: File = new File([blob], 'profile-picture.png', { type: 'image/png' });
|
||||||
}
|
try {
|
||||||
domtoimage.toBlob(div).then(function (blob: Blob) {
|
api.userApi.createProfileImage({ file }).then((res) => {
|
||||||
const file: File = new File([blob], 'profile-picture.png', { type: 'image/png' });
|
lastUpdatedProfilePicture.set(Date.now());
|
||||||
try {
|
dispatch('close');
|
||||||
api.userApi.createProfileImage({ file }).then((res) => {
|
|
||||||
console.log(res);
|
|
||||||
//set store to update profile picture
|
|
||||||
lastUpdatedProfilePicture.set(Date.now());
|
|
||||||
dispatch('close');
|
|
||||||
notificationController.show({
|
|
||||||
type: NotificationType.Info,
|
|
||||||
message: 'Profile picture set.',
|
|
||||||
timeout: 3000,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error [profile-image-cropper]:', err);
|
|
||||||
notificationController.show({
|
notificationController.show({
|
||||||
type: NotificationType.Error,
|
type: NotificationType.Info,
|
||||||
message: 'Error setting profile picture.',
|
message: 'Profile picture set.',
|
||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
});
|
} catch (err) {
|
||||||
|
console.error('Error [profile-image-cropper]:', err);
|
||||||
|
notificationController.show({
|
||||||
|
type: NotificationType.Error,
|
||||||
|
message: 'Error setting profile picture.',
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -58,13 +50,12 @@
|
|||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<div class="flex justify-center place-items-center items-center">
|
<div class="flex justify-center place-items-center items-center">
|
||||||
<div
|
<div
|
||||||
id="profile-picture"
|
bind:this={profilePicture}
|
||||||
class="w-1/2 aspect-square rounded-full overflow-hidden relative flex border-immich-primary border-4"
|
class="w-1/2 aspect-square rounded-full overflow-hidden relative flex border-immich-primary border-4"
|
||||||
>
|
>
|
||||||
<PhotoViewer {publicSharedKey} {asset} on:close={() => console.log('close')} />
|
<PhotoViewer {publicSharedKey} {asset} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="output" />
|
|
||||||
<span class="p-4 flex justify-end">
|
<span class="p-4 flex justify-end">
|
||||||
<Button on:click={handleSetProfilePicture}>
|
<Button on:click={handleSetProfilePicture}>
|
||||||
<p class="">Set as profile picture</p>
|
<p class="">Set as profile picture</p>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
let appendix = '';
|
let appendix = '';
|
||||||
|
|
||||||
lastUpdatedProfilePicture.subscribe((value) => {
|
lastUpdatedProfilePicture.subscribe((value) => {
|
||||||
console.log('isUpdateProfilePicture', value);
|
|
||||||
if (value) {
|
if (value) {
|
||||||
appendix = '?d=' + value;
|
appendix = '?d=' + value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user