Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #525 from OkunaOrg/bug/text-shares-broken
Browse files Browse the repository at this point in the history
🐛 Fix text shares not working
  • Loading branch information
lifenautjoe authored May 8, 2020
2 parents b9b49de + 97e3e11 commit 36cdbbe
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/services/share.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class ShareService {
_queuedShare = null;

_isProcessingShare = true;
var operation = CancelableOperation.fromFuture(_onShare(share));
_activeShares[share] = ShareOperation(share, operation);
_activeShares[share] = ShareOperation(share, _onShare);
_activeShares[share].then(() => _activeShares.remove(share));
_activeShares[share].start();
_isProcessingShare = false;

// Recurse since a new share might have came in while the last was being processed.
Expand Down Expand Up @@ -152,11 +152,10 @@ class ShareService {
if (share.text != null) {
text = share.text;
if (!_validationService.isPostTextAllowedLength(text)) {
String errorMessage = _localizationService
.error__receive_share_text_too_long(ValidationService.POST_MAX_LENGTH);
_toastService.error(
message: errorMessage,
context: _context);
String errorMessage =
_localizationService.error__receive_share_text_too_long(
ValidationService.POST_MAX_LENGTH);
_toastService.error(message: errorMessage, context: _context);
return;
}
}
Expand All @@ -181,6 +180,8 @@ class ShareService {
}

class ShareOperation {
final Future<void> Function(Share) _shareFunction;

Share share;
CancelableOperation shareOperation;
CancelableOperation subOperation;
Expand All @@ -190,7 +191,11 @@ class ShareOperation {
bool _subComplete = false;
FutureOr Function() _callback;

ShareOperation(this.share, this.shareOperation) {
ShareOperation(this.share, Future<void> Function(Share) shareFunction)
: _shareFunction = shareFunction;

void start() {
shareOperation = CancelableOperation.fromFuture(_shareFunction(share));
shareOperation.then((_) {
_shareComplete = true;
_complete();
Expand Down

0 comments on commit 36cdbbe

Please sign in to comment.