add store to update user profile picture when set
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
import domtoimage from 'dom-to-image';
|
import domtoimage from 'dom-to-image';
|
||||||
import type { UserResponseDto } from '@api';
|
import type { UserResponseDto } from '@api';
|
||||||
import { notificationController, NotificationType } from './notification/notification';
|
import { notificationController, NotificationType } from './notification/notification';
|
||||||
import { isUpdateProfilePicture } from '$lib/stores/preferences.store';
|
import { lastUpdatedProfilePicture } from '$lib/stores/preferences.store';
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
console.log(asset);
|
console.log(asset);
|
||||||
});
|
});
|
||||||
@@ -27,14 +27,16 @@
|
|||||||
domtoimage.toBlob(div).then(function (blob: Blob) {
|
domtoimage.toBlob(div).then(function (blob: Blob) {
|
||||||
const file: File = new File([blob], 'profile-picture.png', { type: 'image/png' });
|
const file: File = new File([blob], 'profile-picture.png', { type: 'image/png' });
|
||||||
try {
|
try {
|
||||||
api.userApi.createProfileImage({ file });
|
api.userApi.createProfileImage({ file }).then((res) => {
|
||||||
//set store to update profile picture
|
console.log(res);
|
||||||
isUpdateProfilePicture.set(true);
|
//set store to update profile picture
|
||||||
dispatch('close');
|
lastUpdatedProfilePicture.set(Date.now());
|
||||||
notificationController.show({
|
dispatch('close');
|
||||||
type: NotificationType.Info,
|
notificationController.show({
|
||||||
message: 'Profile picture set.',
|
type: NotificationType.Info,
|
||||||
timeout: 3000,
|
message: 'Profile picture set.',
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error [profile-image-cropper]:', err);
|
console.error('Error [profile-image-cropper]:', err);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { imageLoad } from '$lib/utils/image-load';
|
import { imageLoad } from '$lib/utils/image-load';
|
||||||
import { api, UserResponseDto } from '@api';
|
import { api, UserResponseDto } from '@api';
|
||||||
|
import { lastUpdatedProfilePicture } from '$lib/stores/preferences.store';
|
||||||
|
|
||||||
export let user: UserResponseDto;
|
export let user: UserResponseDto;
|
||||||
export let color: Color = 'primary';
|
export let color: Color = 'primary';
|
||||||
@@ -15,6 +16,14 @@
|
|||||||
export let showTitle = true;
|
export let showTitle = true;
|
||||||
export let autoColor = false;
|
export let autoColor = false;
|
||||||
let showFallback = true;
|
let showFallback = true;
|
||||||
|
let appendix = '';
|
||||||
|
|
||||||
|
lastUpdatedProfilePicture.subscribe((value) => {
|
||||||
|
console.log('isUpdateProfilePicture', value);
|
||||||
|
if (value) {
|
||||||
|
appendix = '?d=' + value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const colorClasses: Record<Color, string> = {
|
const colorClasses: Record<Color, string> = {
|
||||||
primary: 'bg-immich-primary dark:bg-immich-dark-primary text-immich-dark-fg dark:text-immich-fg',
|
primary: 'bg-immich-primary dark:bg-immich-dark-primary text-immich-dark-fg dark:text-immich-fg',
|
||||||
@@ -55,7 +64,7 @@
|
|||||||
>
|
>
|
||||||
{#if user.profileImagePath}
|
{#if user.profileImagePath}
|
||||||
<img
|
<img
|
||||||
src={api.getProfileImageUrl(user.id)}
|
src={api.getProfileImageUrl(user.id) + appendix}
|
||||||
alt="Profile image of {title}"
|
alt="Profile image of {title}"
|
||||||
class="object-cover w-full h-full"
|
class="object-cover w-full h-full"
|
||||||
class:hidden={showFallback}
|
class:hidden={showFallback}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
import { persisted } from 'svelte-local-storage-store';
|
import { persisted } from 'svelte-local-storage-store';
|
||||||
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
const initialTheme = browser && !window.matchMedia('(prefers-color-scheme: dark)').matches ? 'light' : 'dark';
|
const initialTheme = browser && !window.matchMedia('(prefers-color-scheme: dark)').matches ? 'light' : 'dark';
|
||||||
|
|
||||||
@@ -46,3 +47,6 @@ export interface AlbumViewSettings {
|
|||||||
export const albumViewSettings = persisted<AlbumViewSettings>('album-view-settings', {
|
export const albumViewSettings = persisted<AlbumViewSettings>('album-view-settings', {
|
||||||
sortBy: 'Most recent photo',
|
sortBy: 'Most recent photo',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export const lastUpdatedProfilePicture = persisted<Number>('last-updated-profile-picture', 0, {});
|
||||||
Reference in New Issue
Block a user