feat(llc, ui): add support for thumbUrl in video attachment. (#1362)
* feat(llc, ui): add support for thumbUrl in file attachment. Signed-off-by: xsahil03x <[email protected]> * chore(ui): use widget.fit instead of hardcoded fit. Signed-off-by: xsahil03x <[email protected]> * fix analysis Signed-off-by: xsahil03x <[email protected]> Co-authored-by: Salvatore Giordano <[email protected]>
This commit is contained in:
co-authored by
Salvatore Giordano
parent
8b6c59929f
commit
1e9e942c46
@@ -1,5 +1,9 @@
|
||||
## Upcoming
|
||||
|
||||
✅ Added
|
||||
|
||||
- Added `thumbUrl` field in `SendFileResponse` model.
|
||||
|
||||
🐞 Fixed
|
||||
|
||||
- Remove disposed channel clients from the client state.
|
||||
|
||||
@@ -493,36 +493,41 @@ class Channel {
|
||||
|
||||
final isImage = it.type == 'image';
|
||||
final cancelToken = CancelToken();
|
||||
Future<String> future;
|
||||
Future<SendAttachmentResponse> future;
|
||||
if (isImage) {
|
||||
future = sendImage(
|
||||
it.file!,
|
||||
onSendProgress: onSendProgress,
|
||||
cancelToken: cancelToken,
|
||||
extraData: it.extraData,
|
||||
).then((it) => it.file);
|
||||
);
|
||||
} else {
|
||||
future = sendFile(
|
||||
it.file!,
|
||||
onSendProgress: onSendProgress,
|
||||
cancelToken: cancelToken,
|
||||
extraData: it.extraData,
|
||||
).then((it) => it.file);
|
||||
);
|
||||
}
|
||||
_cancelableAttachmentUploadRequest[it.id] = cancelToken;
|
||||
return future.then((url) {
|
||||
return future.then((response) {
|
||||
client.logger.info('Attachment ${it.id} uploaded successfully...');
|
||||
if (isImage) {
|
||||
|
||||
// If the response is SendFileResponse, then we might also be getting
|
||||
// thumbUrl in case of video. So we need to update the attachment with
|
||||
// both the assetUrl and thumbUrl.
|
||||
if (response is SendFileResponse) {
|
||||
updateAttachment(
|
||||
it.copyWith(
|
||||
imageUrl: url,
|
||||
assetUrl: response.file,
|
||||
thumbUrl: response.thumbUrl,
|
||||
uploadState: const UploadState.success(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
updateAttachment(
|
||||
it.copyWith(
|
||||
assetUrl: url,
|
||||
imageUrl: response.file,
|
||||
uploadState: const UploadState.success(),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -157,11 +157,24 @@ class ListDevicesResponse extends _BaseResponse {
|
||||
_$ListDevicesResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Base Model response for [Channel.sendImage] and [Channel.sendFile] api call.
|
||||
@JsonSerializable(createToJson: false)
|
||||
class SendAttachmentResponse extends _BaseResponse {
|
||||
/// The url of the uploaded attachment.
|
||||
late String? file;
|
||||
|
||||
/// Create a new instance from a json
|
||||
static SendAttachmentResponse fromJson(Map<String, dynamic> json) =>
|
||||
_$SendAttachmentResponseFromJson(json);
|
||||
}
|
||||
|
||||
/// Model response for [Channel.sendFile] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class SendFileResponse extends _BaseResponse {
|
||||
/// The url of the uploaded file
|
||||
late String file;
|
||||
class SendFileResponse extends SendAttachmentResponse {
|
||||
/// The url of the uploaded video file.
|
||||
///
|
||||
/// This is only present if the file is a video.
|
||||
String? thumbUrl;
|
||||
|
||||
/// Create a new instance from a json
|
||||
static SendFileResponse fromJson(Map<String, dynamic> json) =>
|
||||
@@ -169,15 +182,7 @@ class SendFileResponse extends _BaseResponse {
|
||||
}
|
||||
|
||||
/// Model response for [Channel.sendImage] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
class SendImageResponse extends _BaseResponse {
|
||||
/// The url of the uploaded file
|
||||
late String file;
|
||||
|
||||
/// Create a new instance from a json
|
||||
static SendImageResponse fromJson(Map<String, dynamic> json) =>
|
||||
_$SendImageResponseFromJson(json);
|
||||
}
|
||||
typedef SendImageResponse = SendAttachmentResponse;
|
||||
|
||||
/// Model response for [Channel.sendReaction] api call
|
||||
@JsonSerializable(createToJson: false)
|
||||
|
||||
@@ -97,15 +97,17 @@ ListDevicesResponse _$ListDevicesResponseFromJson(Map<String, dynamic> json) =>
|
||||
.toList() ??
|
||||
[];
|
||||
|
||||
SendAttachmentResponse _$SendAttachmentResponseFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
SendAttachmentResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..file = json['file'] as String?;
|
||||
|
||||
SendFileResponse _$SendFileResponseFromJson(Map<String, dynamic> json) =>
|
||||
SendFileResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..file = json['file'] as String;
|
||||
|
||||
SendImageResponse _$SendImageResponseFromJson(Map<String, dynamic> json) =>
|
||||
SendImageResponse()
|
||||
..duration = json['duration'] as String?
|
||||
..file = json['file'] as String;
|
||||
..file = json['file'] as String?
|
||||
..thumbUrl = json['thumb_url'] as String?;
|
||||
|
||||
SendReactionResponse _$SendReactionResponseFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
|
||||
Reference in New Issue
Block a user