feat: update profile when adding preexisting url

This commit is contained in:
problematicconsumer
2023-09-16 14:02:26 +03:30
parent 03c4cc7330
commit 22d1cd17e2
2 changed files with 21 additions and 0 deletions

View File

@@ -71,6 +71,15 @@ class ProfilesRepositoryImpl
}) {
return exceptionHandler(
() async {
final existingProfile = await profilesDao.getProfileByUrl(url);
if (existingProfile != null) {
loggy.info("profile with url[$url] already exists, updating");
final baseProfile = markAsActive
? existingProfile.copyWith(active: true)
: existingProfile;
return update(baseProfile).run();
}
final profileId = const Uuid().v4();
return fetch(url, profileId)
.flatMap(