Uh oh!
There was an error while loading. Please reload this page.
Convert backupToInbox method from Promise to Future - #590
Conversation
ivan-ushakov
commented
Oct 2, 2021
I found that it will be much easy to have service methods implemented without any internal async. So we could decide how we run that method when we use it in chain. |
ivan-ushakov
commented
Oct 2, 2021
I did mistake with queue dispatching and will fix it today. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tomholub
commented
Oct 2, 2021
@Kharchevskyi does this look good to you? Please have a look. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tomholub
commented
Oct 4, 2021
Thank you Anton. I'm unsure if your comments still apply after the PR is reworked after my comments - let's see after the rework. |
tomholub
left a comment
There was a problem hiding this comment.
for me, this is exactly what I was looking for. Thank you!
@Kharchevskyi could you please give this a second look now?
tomholub
left a comment
There was a problem hiding this comment.
I suppose Anton is busy. To me it looks good. I'll try the app as well, and merge it if works well.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Pull request was converted to draft
Uh oh!
There was an error while loading. Please reload this page.
tomholub
commented
Oct 6, 2021
I may be able to arrange dropping support for iOS 14. That means we'd transition to iOS 15 async/await syntax and stop it with these workarounds. I'll have more news soon. |
ivan-ushakov
commented
Oct 8, 2021
Could I continue now with this issue and try |
tomholub
commented
Oct 9, 2021
Yes - please try that. |
| let encryptedPrv = try self.core.generateKey(passphrase: passPhrase, variant: .curve25519, userIds: [userId]) | ||
| try awaitPromise(self.backupService.backupToInbox(keys: [encryptedPrv.key], for: self.user)) | ||
| let semaphore = DispatchSemaphore(value: 0) |
There was a problem hiding this comment.
This method uses a lot of other methods and too big for the first step. So I just wait for async task.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
tomholub
left a comment
There was a problem hiding this comment.
LGTM. The real refactoring will start once everything is async/await - it will highlight superfluous code more obviously. @sosnovsky please have a look for Swift-specific issues, see if it looks ok to you.
| let encryptedPrv = try self.core.generateKey(passphrase: passPhrase, variant: .curve25519, userIds: [userId]) | ||
| try awaitPromise(self.backupService.backupToInbox(keys: [encryptedPrv.key], for: self.user)) | ||
| let semaphore = DispatchSemaphore(value: 0) |
sosnovsky
left a comment
There was a problem hiding this comment.
Updated code looks good for me - async/await made it much more clear and easy to read, looking forward to next steps of async refactoring 🚀
tomholub
commented
Oct 13, 2021
@ivan-ushakov anything left to do for this PR to be able to mark it as ready? |
ivan-ushakov
commented
Oct 13, 2021
I want to do some tests today. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| Task { | ||
| do { | ||
| try await composeMessageService.encryptAndSend(message: message, threadId: input.threadId) | ||
| handleSuccessfullySentMessage() |
There was a problem hiding this comment.
Since every view controller is marked with @MainActor we could simply call methods from task and they will be invoked on the main thread.
…ub.com:FlowCrypt/flowcrypt-ios into feature/issue-543-convert-backupToInbox-method
tomholub
commented
Oct 14, 2021
@Kharchevskyi does this look good to you? If the tests pass I'll merge it, but if there is something to change, we let me know and we'll get it addressed in the next PR. |
close#543
Tests(delete all except exactly one):
To be filled by reviewers
I have reviewed that this PR... (tick whichever items you personally focused on during this review):