mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 02:43:50 +02:00
feat: delete chat files when deleting chat
This commit is contained in:
parent
13f57a0817
commit
35e1aab154
6 changed files with 21 additions and 6 deletions
|
@ -179,7 +179,7 @@ packages:
|
|||
description:
|
||||
path: "packages/flutter_community_chat_interface"
|
||||
ref: HEAD
|
||||
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6
|
||||
resolved-ref: "8544711a477aa761c8d48a6e5798cd63feb9b6b9"
|
||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
@ -188,7 +188,7 @@ packages:
|
|||
description:
|
||||
path: "packages/flutter_community_chat_view"
|
||||
ref: HEAD
|
||||
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6
|
||||
resolved-ref: "8544711a477aa761c8d48a6e5798cd63feb9b6b9"
|
||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
|
|
@ -40,6 +40,7 @@ class FirebaseCommunityChatDataProvider extends CommunityChatInterface {
|
|||
|
||||
_chatService = FirebaseChatService(
|
||||
db: db,
|
||||
storage: storage,
|
||||
userService: _userService,
|
||||
options: firebaseChatOptions,
|
||||
);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
import 'dart:async';
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
import 'package:flutter_community_chat_firebase/config/firebase_chat_options.dart';
|
||||
import 'package:flutter_community_chat_firebase/dto/firebase_chat_document.dart';
|
||||
import 'package:flutter_community_chat_interface/flutter_community_chat_interface.dart';
|
||||
|
@ -12,11 +13,13 @@ import 'firebase_user_service.dart';
|
|||
class FirebaseChatService {
|
||||
FirebaseChatService({
|
||||
required this.db,
|
||||
required this.storage,
|
||||
required this.userService,
|
||||
required this.options,
|
||||
});
|
||||
|
||||
FirebaseFirestore db;
|
||||
FirebaseStorage storage;
|
||||
FirebaseUserService userService;
|
||||
FirebaseChatOptions options;
|
||||
|
||||
|
@ -233,7 +236,18 @@ class FirebaseChatService {
|
|||
.delete();
|
||||
}
|
||||
|
||||
await db.collection(options.chatsCollectionName).doc(chat.id).delete();
|
||||
if (chat.id != null) {
|
||||
await db.collection(options.chatsCollectionName).doc(chat.id).delete();
|
||||
await storage
|
||||
.ref(options.chatsCollectionName)
|
||||
.child(chat.id!)
|
||||
.listAll()
|
||||
.then((value) {
|
||||
for (var element in value.items) {
|
||||
element.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ packages:
|
|||
description:
|
||||
path: "packages/flutter_community_chat_interface"
|
||||
ref: HEAD
|
||||
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6
|
||||
resolved-ref: "8544711a477aa761c8d48a6e5798cd63feb9b6b9"
|
||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
|
|
@ -186,7 +186,7 @@ packages:
|
|||
description:
|
||||
path: "packages/flutter_community_chat_interface"
|
||||
ref: HEAD
|
||||
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6
|
||||
resolved-ref: "8544711a477aa761c8d48a6e5798cd63feb9b6b9"
|
||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
|
|
@ -179,7 +179,7 @@ packages:
|
|||
description:
|
||||
path: "packages/flutter_community_chat_interface"
|
||||
ref: HEAD
|
||||
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6
|
||||
resolved-ref: "8544711a477aa761c8d48a6e5798cd63feb9b6b9"
|
||||
url: "https://github.com/Iconica-Development/flutter_community_chat.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
|
Loading…
Reference in a new issue