import { BehaviorSubject, Observable } from 'rxjs'; import { Attachment } from 'stream-chat'; import { ChannelService } from './channel.service'; import { NotificationService } from './notification.service'; import { AttachmentUpload, AudioRecording } from './types'; import { ChatClientService } from './chat-client.service'; import { MessageService } from './message.service'; import * as i0 from "@angular/core"; /** * The `AttachmentService` manages the uploads of a message input. * * You can read more about [uploads](/chat/docs/javascript/file_uploads/) in the Stream API documentation. You can use Stream's API or the dashboard to customize the [file](/chat/docs/javascript/app_setting_overview/#file-uploads) and [image upload](/chat/docs/javascript/app_setting_overview/#image-uploads) configuration. */ export declare class AttachmentService { private channelService; private notificationService; private chatClientService; private messageService; /** * Emits the number of uploads in progress. * * You can increment and decrement this counter if you're using custom attachments and want to disable message sending until all attachments are uploaded. * * The SDK will handle updating this counter for built-in attachments, but for custom attachments you should take care of this. */ attachmentUploadInProgressCounter$: BehaviorSubject; /** * Emits the state of the uploads ([`AttachmentUpload[]`](https://github.com/GetStream/stream-chat-angular/blob/master/projects/stream-chat-angular/src/lib/types.ts)), it adds a state (`success`, `error` or `uploading`) to each file the user selects for upload. It is used by the [`AttachmentPreviewList`](/chat/docs/sdk/angular/components/AttachmentPreviewListComponent/) to display the attachment previews. */ attachmentUploads$: Observable; /** * You can get and set the list if uploaded custom attachments * * By default the SDK components won't display these, but you can provide your own `customAttachmentPreviewListTemplate$` and `customAttachmentListTemplate$` for the [`CustomTemplatesService`](/chat/docs/sdk/angular/services/CustomTemplatesService/). */ customAttachments$: BehaviorSubject; /** * The current number of attachments */ attachmentsCounter$: Observable; /** * The maximum number of attachments allowed for a message. * * The maximum is 30, you can set it to lower, but not higher. */ maxNumberOfAttachments: number; private attachmentUploadsSubject; private appSettings; private attachmentLimitNotificationHide?; constructor(channelService: ChannelService, notificationService: NotificationService, chatClientService: ChatClientService, messageService: MessageService); /** * Resets the attachments uploads (for example after the message with the attachments sent successfully) */ resetAttachmentUploads(): void; /** * Upload a voice recording * @param audioRecording * @returns A promise with true or false. If false is returned the upload was canceled because of a client side error. The error is emitted via the `NotificationService`. */ uploadVoiceRecording(audioRecording: AudioRecording): Promise; /** * Uploads the selected files, and creates preview for image files. The result is propagated throught the `attachmentUploads$` stream. * @param fileList The files selected by the user, if you have Blobs instead of Files, you can convert them with this method: https://developer.mozilla.org/en-US/docs/Web/API/File/File * @returns A promise with true or false. If false is returned the upload was canceled because of a client side error. The error is emitted via the `NotificationService`. */ filesSelected(fileList: FileList | File[] | null): Promise; /** * You can add custom `image`, `video` and `file` attachments using this method. * * Note: If you just want to use your own CDN for file uploads, you don't necessary need this method, you can just specify you own upload function in the [`ChannelService`](/chat/docs/sdk/angular/services/ChannelService/) * @param attachment * * Will set `isCustomAttachment` to `true` on the attachment. This is a non-standard field, other SDKs will ignore this property. */ addAttachment(attachment: Attachment): void; /** * Retries to upload an attachment. * @param file * @returns A promise with the result */ retryAttachmentUpload(file: File): Promise; /** * Deletes an attachment, the attachment can have any state (`error`, `uploading` or `success`). * @param upload */ deleteAttachment(upload: AttachmentUpload): Promise; /** * Maps the current uploads to a format that can be sent along with the message to the Stream API. * @returns the attachments */ mapToAttachments(): Attachment[]; /** * Maps attachments received from the Stream API to uploads. This is useful when editing a message. * @param attachments Attachemnts received with the message */ createFromAttachments(attachments: Attachment[]): void; private createPreview; private uploadAttachments; private areAttachmentsHaveValidExtension; private areAttachmentsHaveValidSize; private isWithinLimit; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }