-
Notifications
You must be signed in to change notification settings - Fork 1
fix/session-name-not-updated-after-change-on-another-device #1066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ea980b0
6acfe62
bd712da
25b9c9b
78b6b7f
8283bfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| struct BatchError: Error { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, there is 99% chance it will not be used ever again ^^' |
||
| let errors: [Error] | ||
|
|
||
| var localizedDescription: String { | ||
| let failureCount = errors.count | ||
|
|
||
| var description = "Batch operation completed with \(failureCount) failures" | ||
|
|
||
| if !errors.isEmpty { | ||
| description += "\n\nFailure details:" | ||
| for (index, error) in errors.enumerated() { | ||
| description += "\n\(index + 1). \(error.localizedDescription)" | ||
| } | ||
| } | ||
|
|
||
| return description | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| // | ||
|
|
||
| import Foundation | ||
| import Combine | ||
|
|
||
| func waitFor<T>(_ operation: @escaping () async throws -> T) throws -> T { | ||
| guard !Thread.isMainThread else { | ||
|
|
@@ -28,3 +29,18 @@ func waitFor<T>(_ operation: @escaping () async throws -> T) throws -> T { | |
| } | ||
| return result | ||
| } | ||
|
|
||
| extension Future where Failure == Error { | ||
| convenience init(asyncOperation: @escaping () async throws -> Output) { | ||
| self.init { promise in | ||
| Task { | ||
| do { | ||
| let result = try await asyncOperation() | ||
| promise(.success(result)) | ||
| } catch { | ||
| promise(.failure(error)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+33
to
+46
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using this to bridge Future client code and refactored async code to get rid of the callbacks |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Created by Lunar on 14.07.25. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| extension Sequence { | ||
| func partitioned(by condition: (Element) -> Bool) -> (matching: [Element], nonMatching: [Element]) { | ||
| var matching = [Element]() | ||
| var nonMatching = [Element]() | ||
|
|
||
| for element in self { | ||
| if condition(element) { | ||
| matching.append(element) | ||
| } else { | ||
| nonMatching.append(element) | ||
| } | ||
| } | ||
|
|
||
| return (matching, nonMatching) | ||
| } | ||
| } | ||
|
Comment on lines
+6
to
+21
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Searched for some library that has this specifically but didn't find any |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked the call chain of the method and in the end the only error handling was this line of logging, so I moved it here and made the method not throw, to handle the nil cases conveniently from the client code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Behold, useless error throwing. Good call 👍