-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
run SendRelayedMessageUtil.sendMultipleMsgs() in background #3506
Conversation
To test the changes in this pull request, install this apk: |
@@ -362,7 +362,7 @@ public void onActivityResult(final int reqCode, int resultCode, Intent data) { | |||
for (int i = 0; i < uriCount; i++) { | |||
uriList.add(multipleUris.getItemAt(i).getUri()); | |||
} | |||
askSendingFiles(uriList, () -> SendRelayedMessageUtil.sendMultipleMsgs(this, chatId, uriList, null)); | |||
askSendingFiles(uriList, () -> SendRelayedMessageUtil.sendMultipleMsgs(this, chatId, uriList)); |
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 think, it would have been easier, to leave the existing function as is and dispatch to background from the caller:
askSendingFiles(uriList, () -> {
Util.runOnAnyBackgroundThread(() -> {
SendRelayedMessageUtil.sendMultipleMsgs(this, chatId, uriList, null));
}
}
the thing with the newly added function is that it adds to the mess of not knowing if caller or implementation dispatch to background (as a rule of thumb, to separate concerns, i would go for caller if in doubt: the function remains simple and synchronous, it easier to understand, testable (no issue here) and flexible. the caller handles the complexity of concurrency)
also, we would have two function with nearly the same functionality but totally different names
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.
that is what I did, they are two different functions now, one is synchronous and private, and the public one is async, it is only used in a single place at the moment, so I could do as suggested and call it in background from caller, that doesn't protect against making the same mistake again, but that is just precautions for hypothetical futures, so I will go with the simpler suggested solution for now
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.
as discussed above, i would rethink who dispatches.
however, if there are good reasons to go the existing way, i am also fine with that, the suggestion is no blocker :)
de02012
to
df5ba2e
Compare
close #3502