mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:39:37 -05:00 
			
		
		
		
	Added timeout option for notification component
This commit is contained in:
		
							parent
							
								
									bef38c670c
								
							
						
					
					
						commit
						44ccb1eec1
					
				@ -51,7 +51,7 @@
 | 
				
			|||||||
	onMount(() => {
 | 
						onMount(() => {
 | 
				
			||||||
		setTimeout(() => {
 | 
							setTimeout(() => {
 | 
				
			||||||
			notificationController.removeNotificationById(notificationInfo.id);
 | 
								notificationController.removeNotificationById(notificationInfo.id);
 | 
				
			||||||
		}, 3000);
 | 
							}, notificationInfo.timeout);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -9,17 +9,36 @@ export class ImmichNotification {
 | 
				
			|||||||
	id = new Date().getTime();
 | 
						id = new Date().getTime();
 | 
				
			||||||
	type!: NotificationType;
 | 
						type!: NotificationType;
 | 
				
			||||||
	message!: string;
 | 
						message!: string;
 | 
				
			||||||
 | 
						timeout = 3000;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class ImmichNotificationDto {
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Notification type
 | 
				
			||||||
 | 
						 * @type {NotificationType} [Info, Error]
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						type: NotificationType = NotificationType.Info;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Notification message
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						message = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Timeout in miliseconds
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						timeout = 3000;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
function createNotificationList() {
 | 
					function createNotificationList() {
 | 
				
			||||||
	const notificationList = writable<ImmichNotification[]>([]);
 | 
						const notificationList = writable<ImmichNotification[]>([]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const show = ({ message = '', type = NotificationType.Info }) => {
 | 
						const show = (notificationInfo: ImmichNotificationDto) => {
 | 
				
			||||||
		const notification = new ImmichNotification();
 | 
							const newNotification = new ImmichNotification();
 | 
				
			||||||
		notification.message = message;
 | 
							newNotification.message = notificationInfo.message;
 | 
				
			||||||
		notification.type = type;
 | 
							newNotification.type = notificationInfo.type;
 | 
				
			||||||
 | 
							newNotification.timeout = notificationInfo.timeout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		notificationList.update((currentList) => [...currentList, notification]);
 | 
							notificationList.update((currentList) => [...currentList, newNotification]);
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const removeNotificationById = (id: number) => {
 | 
						const removeNotificationById = (id: number) => {
 | 
				
			||||||
 | 
				
			|||||||
@ -38,9 +38,10 @@ export const openFileUploadDialog = (uploadType: UploadType) => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			if (files.length > 50) {
 | 
								if (files.length > 50) {
 | 
				
			||||||
				notificationController.show({
 | 
									notificationController.show({
 | 
				
			||||||
 | 
										type: NotificationType.Error,
 | 
				
			||||||
					message: `Cannot upload more than 50 files at a time - you are uploading ${files.length} files. 
 | 
										message: `Cannot upload more than 50 files at a time - you are uploading ${files.length} files. 
 | 
				
			||||||
          Please use the CLI tool if you need to upload more than 50 files.`,
 | 
					          Please use the CLI tool if you need to upload more than 50 files.`,
 | 
				
			||||||
					type: NotificationType.Error
 | 
										timeout: 5000
 | 
				
			||||||
				});
 | 
									});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				return;
 | 
									return;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user