Skip to content

Commit

Permalink
fixup! fixup! LA-1352 sync deleted recieved shares with local db
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaledNjim committed Nov 12, 2024
1 parent b5f3a21 commit 98800cf
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'dart:developer';
import 'package:domain/domain.dart';
import 'package:collection/collection.dart';

class RemoveDeletedReceivedShareFromLocalDatabaseInteractor {
final ReceivedShareRepository _receivedShareRepository;
Expand All @@ -9,13 +9,19 @@ class RemoveDeletedReceivedShareFromLocalDatabaseInteractor {

Future<void> execute(
List<ReceivedShare> receivedShares, String recipient) async {
var localReceivedShares = await _receivedShareRepository
.getAllReceivedShareOfflineByRecipient(recipient);
final receivedShareIds = receivedShares.map((received) => received.shareId).toSet();
for (final local in localReceivedShares) {
if (!receivedShareIds.contains(local.shareId)) {
await _receivedShareRepository.disableOffline(local.shareId, local.localPath ?? '');
try {
var localReceivedShares = await _receivedShareRepository
.getAllReceivedShareOfflineByRecipient(recipient);
final receivedShareIds =
receivedShares.map((received) => received.shareId).toSet();
for (final local in localReceivedShares) {
if (!receivedShareIds.contains(local.shareId)) {
await _receivedShareRepository.disableOffline(
local.shareId, local.localPath ?? '');
}
}
} catch (exception) {
log('RemoveDeletedReceivedShareFromLocalDatabaseInteractor: $exception');
}
}
}

0 comments on commit 98800cf

Please sign in to comment.