feat: delete chat files when deleting chat

This commit is contained in:
Stein Milder 2022-11-25 08:57:18 +01:00
parent 13f57a0817
commit 35e1aab154
6 changed files with 21 additions and 6 deletions

View file

@ -179,7 +179,7 @@ packages:
description: description:
path: "packages/flutter_community_chat_interface" path: "packages/flutter_community_chat_interface"
ref: HEAD ref: HEAD
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6 resolved-ref: "8544711a477aa761c8d48a6e5798cd63feb9b6b9"
url: "https://github.com/Iconica-Development/flutter_community_chat.git" url: "https://github.com/Iconica-Development/flutter_community_chat.git"
source: git source: git
version: "0.0.1" version: "0.0.1"
@ -188,7 +188,7 @@ packages:
description: description:
path: "packages/flutter_community_chat_view" path: "packages/flutter_community_chat_view"
ref: HEAD ref: HEAD
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6 resolved-ref: "8544711a477aa761c8d48a6e5798cd63feb9b6b9"
url: "https://github.com/Iconica-Development/flutter_community_chat.git" url: "https://github.com/Iconica-Development/flutter_community_chat.git"
source: git source: git
version: "0.0.1" version: "0.0.1"

View file

@ -40,6 +40,7 @@ class FirebaseCommunityChatDataProvider extends CommunityChatInterface {
_chatService = FirebaseChatService( _chatService = FirebaseChatService(
db: db, db: db,
storage: storage,
userService: _userService, userService: _userService,
options: firebaseChatOptions, options: firebaseChatOptions,
); );

View file

@ -4,6 +4,7 @@
import 'dart:async'; import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart'; 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/config/firebase_chat_options.dart';
import 'package:flutter_community_chat_firebase/dto/firebase_chat_document.dart'; import 'package:flutter_community_chat_firebase/dto/firebase_chat_document.dart';
import 'package:flutter_community_chat_interface/flutter_community_chat_interface.dart'; import 'package:flutter_community_chat_interface/flutter_community_chat_interface.dart';
@ -12,11 +13,13 @@ import 'firebase_user_service.dart';
class FirebaseChatService { class FirebaseChatService {
FirebaseChatService({ FirebaseChatService({
required this.db, required this.db,
required this.storage,
required this.userService, required this.userService,
required this.options, required this.options,
}); });
FirebaseFirestore db; FirebaseFirestore db;
FirebaseStorage storage;
FirebaseUserService userService; FirebaseUserService userService;
FirebaseChatOptions options; FirebaseChatOptions options;
@ -233,7 +236,18 @@ class FirebaseChatService {
.delete(); .delete();
} }
if (chat.id != null) {
await db.collection(options.chatsCollectionName).doc(chat.id).delete(); 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();
}
});
}
} }
} }
} }

View file

@ -228,7 +228,7 @@ packages:
description: description:
path: "packages/flutter_community_chat_interface" path: "packages/flutter_community_chat_interface"
ref: HEAD ref: HEAD
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6 resolved-ref: "8544711a477aa761c8d48a6e5798cd63feb9b6b9"
url: "https://github.com/Iconica-Development/flutter_community_chat.git" url: "https://github.com/Iconica-Development/flutter_community_chat.git"
source: git source: git
version: "0.0.1" version: "0.0.1"

View file

@ -186,7 +186,7 @@ packages:
description: description:
path: "packages/flutter_community_chat_interface" path: "packages/flutter_community_chat_interface"
ref: HEAD ref: HEAD
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6 resolved-ref: "8544711a477aa761c8d48a6e5798cd63feb9b6b9"
url: "https://github.com/Iconica-Development/flutter_community_chat.git" url: "https://github.com/Iconica-Development/flutter_community_chat.git"
source: git source: git
version: "0.0.1" version: "0.0.1"

View file

@ -179,7 +179,7 @@ packages:
description: description:
path: "packages/flutter_community_chat_interface" path: "packages/flutter_community_chat_interface"
ref: HEAD ref: HEAD
resolved-ref: f7baf3667f92282c56ef54a874b4ba8ebde9fcd6 resolved-ref: "8544711a477aa761c8d48a6e5798cd63feb9b6b9"
url: "https://github.com/Iconica-Development/flutter_community_chat.git" url: "https://github.com/Iconica-Development/flutter_community_chat.git"
source: git source: git
version: "0.0.1" version: "0.0.1"