diff --git a/services/src/main/java/com/twofasapp/services/data/ServicesRepositoryImpl.kt b/services/src/main/java/com/twofasapp/services/data/ServicesRepositoryImpl.kt index cf478ba3..433d2620 100644 --- a/services/src/main/java/com/twofasapp/services/data/ServicesRepositoryImpl.kt +++ b/services/src/main/java/com/twofasapp/services/data/ServicesRepositoryImpl.kt @@ -80,6 +80,18 @@ internal class ServicesRepositoryImpl( return } + // Remove duplicates + val matchingServices = localData.selectAll().filter { it.assignedDomains.contains(domain.lowercase()) } + + matchingServices.forEach { matched -> + localData.updateServiceSuspend( + matched.copy( + assignedDomains = matched.assignedDomains.minus(domain.lowercase()), + updatedAt = timeProvider.systemCurrentTime(), + ) + ) + } + localData.updateServiceSuspend( service.copy( assignedDomains = service.assignedDomains.plus(domain.lowercase()),