uploadPrivateAttachment method

void uploadPrivateAttachment(
  1. String identity,
  2. String name,
  3. File file,
  4. Function? onUploadSuccess,
)

Implementation

void uploadPrivateAttachment(
    String identity, String name, File file, Function? onUploadSuccess) {
  networkRequestHandler(
      apiCall: () =>
          apiClient.uploadFile(file, onSendProgress: (sent, total) {
            privateMessageProgress = sent / total;
            sendUploadAttachmentEvent(ShowProgress(privateMessageProgress));
          }),
      onSuccess: (data) {
        if (onUploadSuccess != null) {
          onUploadSuccess();
        }
        resetProgress();
        sendPrivateMessage(identity, name, data?.url ?? "");
      });
}