added hard delete

This commit is contained in:
Deven Joshi
2021-11-12 16:42:33 +05:30
parent a3cce7ffff
commit 821d8ee0f0
4 changed files with 16 additions and 6 deletions
+6
View File
@@ -1,3 +1,9 @@
## Upcoming
✅ Added
- Added hard delete functionality.
## 3.2.0 ## 3.2.0
🐞 Fixed 🐞 Fixed
@@ -648,7 +648,7 @@ class Channel {
} }
/// Deletes the [message] from the channel. /// Deletes the [message] from the channel.
Future<EmptyResponse> deleteMessage(Message message) async { Future<EmptyResponse> deleteMessage(Message message, {bool? hard}) async {
// Directly deleting the local messages which are not yet sent to server // Directly deleting the local messages which are not yet sent to server
if (message.status == MessageSendingStatus.sending || if (message.status == MessageSendingStatus.sending ||
message.status == MessageSendingStatus.failed) { message.status == MessageSendingStatus.failed) {
@@ -675,7 +675,7 @@ class Channel {
state?.addMessage(message); state?.addMessage(message);
final response = await _client.deleteMessage(message.id); final response = await _client.deleteMessage(message.id, hard: hard);
state?.addMessage(message.copyWith(status: MessageSendingStatus.sent)); state?.addMessage(message.copyWith(status: MessageSendingStatus.sent));
@@ -1213,8 +1213,8 @@ class StreamChatClient {
); );
/// Deletes the given message /// Deletes the given message
Future<EmptyResponse> deleteMessage(String messageId) => Future<EmptyResponse> deleteMessage(String messageId, {bool? hard}) =>
_chatApi.message.deleteMessage(messageId); _chatApi.message.deleteMessage(messageId, hard: hard);
/// Get a message by [messageId] /// Get a message by [messageId]
Future<GetMessageResponse> getMessage(String messageId) => Future<GetMessageResponse> getMessage(String messageId) =>
@@ -80,10 +80,14 @@ class MessageApi {
/// Deletes the given [messageId] /// Deletes the given [messageId]
Future<EmptyResponse> deleteMessage( Future<EmptyResponse> deleteMessage(
String messageId, String messageId, {
) async { bool? hard,
}) async {
final response = await _client.delete( final response = await _client.delete(
'/messages/$messageId', '/messages/$messageId',
queryParameters: {
if (hard != null) 'hard': hard,
},
); );
return EmptyResponse.fromJson(response.data); return EmptyResponse.fromJson(response.data);
} }