removeFeedFromHashtags method
Implementation
Future<void> removeFeedFromHashtags({
required final String feedId,
required final List<String> hashtags,
}) async {
for (final hashtag in hashtags) {
final splittedHashtag = hashtag.split(' ');
assert(splittedHashtag.length > 1, 'Invalid hashtag - $hashtag');
}
try {
final futures = <Future>[];
for (var hashtag in hashtags) {
hashtag = hashtag.replaceAll('#', '');
final hashtagFeedRef = PeamanReferenceHelper.hashtagFeedsCol(
hashtag: hashtag,
).doc(feedId);
final future = hashtagFeedRef.delete().catchError((e) {
print(e);
print('Error!!!: Deleting feed - $feedId from hashtag - $hashtag');
});
futures.add(future);
}
await Future.wait(futures);
print('Success: Removing feed - $feedId from hashtags - $hashtags');
} catch (e) {
print(e);
print('Error!!!: Removing feed - $feedId from hashtags - $hashtags');
}
}