Skip to content

Commit b99c194

Browse files
authored
Refactor FXIOS-13008 [Remove Monadic Deferred Operators] Replace >>== operator under RustPlaces.deleteBookmarksWithURL(url:) (#28856)
Refactor FXIOS-13008 [Remove Monadic Deferred Operators] replace >>== operator
1 parent aa19193 commit b99c194

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

firefox-ios/Storage/Rust/RustPlaces.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -376,17 +376,21 @@ public class RustPlaces: @unchecked Sendable, BookmarksHandler {
376376
}
377377

378378
public func deleteBookmarksWithURL(url: String) -> Success {
379-
return getBookmarksWithURL(url: url) >>== { bookmarks in
380-
let deferreds = bookmarks.map({ self.deleteBookmarkNode(guid: $0.guid) })
381-
return all(deferreds).bind { results in
382-
if let error = results.first(where: { $0.isFailure })?.failureValue {
383-
return deferMaybe(error)
379+
return getBookmarksWithURL(url: url)
380+
.bind { res in
381+
guard case .success(let bookmarks) = res else {
382+
return Deferred(value: Maybe(failure: res.failureValue!))
383+
}
384+
let deferreds = bookmarks.map({ self.deleteBookmarkNode(guid: $0.guid) })
385+
return all(deferreds).bind { results in
386+
if let error = results.first(where: { $0.isFailure })?.failureValue {
387+
return deferMaybe(error)
388+
}
389+
390+
self.notificationCenter.post(name: .BookmarksUpdated, withObject: self)
391+
return succeed()
384392
}
385-
386-
self.notificationCenter.post(name: .BookmarksUpdated, withObject: self)
387-
return succeed()
388393
}
389-
}
390394
}
391395

392396
public func createFolder(parentGUID: GUID, title: String,

0 commit comments

Comments
 (0)