Skip to content

Commit

Permalink
TF-2532 Only clear old data stream when add object to stream in share…
Browse files Browse the repository at this point in the history
… file

Signed-off-by: dab246 <[email protected]>
  • Loading branch information
dab246 committed Feb 5, 2024
1 parent b590786 commit 181e1ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ class MailboxDashBoardController extends ReloadableController {
_emailAddressStreamSubscription =
_emailReceiveManager.pendingEmailAddressInfo.stream.listen((emailAddress) {
if (emailAddress?.email?.isNotEmpty == true) {
_emailReceiveManager.clearPendingEmailAddress();
goToComposer(ComposerArguments.fromEmailAddress(emailAddress!));
}
});
Expand All @@ -416,7 +415,6 @@ class MailboxDashBoardController extends ReloadableController {
_emailContentStreamSubscription =
_emailReceiveManager.pendingEmailContentInfo.stream.listen((emailContent) {
if (emailContent?.content.isNotEmpty == true) {
_emailReceiveManager.clearPendingEmailContent();
goToComposer(ComposerArguments.fromContentShared([emailContent!].asHtmlString));
}
});
Expand All @@ -426,7 +424,6 @@ class MailboxDashBoardController extends ReloadableController {
_fileReceiveManagerStreamSubscription =
_emailReceiveManager.pendingFileInfo.stream.listen((listFile) {
if (listFile.isNotEmpty) {
_emailReceiveManager.clearPendingFileInfo();
goToComposer(ComposerArguments.fromFileShared(listFile));
}
});
Expand Down
18 changes: 8 additions & 10 deletions lib/main/utils/email_receive_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ class EmailReceiveManager {
}

void setPendingEmailAddress(EmailAddress emailAddress) async {
clearPendingEmailAddress();
_clearPendingEmailAddress();
_pendingEmailAddressInfo.add(emailAddress);
}

void setPendingEmailContent(EmailContent emailContent) async {
clearPendingEmailAddress();
_clearPendingEmailContent();
_pendingEmailContentInfo.add(emailContent);
}

void clearPendingEmailContent() {
void _clearPendingEmailContent() {
if (_pendingEmailContentInfo.isClosed) {
_pendingEmailContentInfo = BehaviorSubject.seeded(null);
} else {
_pendingEmailContentInfo.add(null);
}
}

void clearPendingEmailAddress() {
void _clearPendingEmailAddress() {
if(_pendingEmailAddressInfo.isClosed) {
_pendingEmailAddressInfo = BehaviorSubject.seeded(null);
} else {
Expand All @@ -56,22 +56,20 @@ class EmailReceiveManager {

void closeEmailReceiveManagerStream() {
_pendingEmailAddressInfo.close();
_pendingEmailContentInfo.close();
_pendingFileInfo.close();
}

void setPendingFileInfo(List<SharedMediaFile> list) async {
clearPendingFileInfo();
_clearPendingFileInfo();
_pendingFileInfo.add(list);
}

void clearPendingFileInfo() {
void _clearPendingFileInfo() {
if(_pendingFileInfo.isClosed) {
_pendingFileInfo = BehaviorSubject.seeded(List.empty(growable: true));
} else {
_pendingFileInfo.add(List.empty(growable: true));
}
}

void closeFileSharingStream() {
_pendingFileInfo.close();
}
}

0 comments on commit 181e1ec

Please sign in to comment.