Skip to content
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

Trigger dispose before onClose in BaseController #2957

Open
wants to merge 1 commit into
base: refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/features/base/base_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,10 @@ abstract class BaseController extends GetxController
authorizationInterceptors.clear();
await cachingManager.closeHive();
}

@override
void onClose() {
super.onClose();
dispose();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please test again on web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only place we have concern about dispose() callback is ComposerController, so it's fine

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many controllers inherit from it. Are you sure other controllers are not affected?. Please test the features on the website: DestinationPicker, Signature, Forward Email, Vacation, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only care about the one overriding dispose. If originally dispose "does nothing" (as its author said), why do we have to care if its not modified?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only care about the one overriding dispose. If originally dispose "does nothing" (as its author said), why do we have to care if its not modified?

The problem here is that we handle many things in the dispose function. In the current version, if dispose is not called, the handlers will not be executed. And now if you call it in onClose maybe some of those actions will throw an error, we don't know. So we need to check that controllers inherit from BaseController.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure that you have tested most of the app's features and that they are working properly with this change.

}
}
2 changes: 0 additions & 2 deletions lib/features/composer/presentation/composer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class ComposerController extends BaseController with DragDropFileMixin {
ButtonState _sendButtonState = ButtonState.enabled;

late Worker uploadInlineImageWorker;
late Worker dashboardViewStateWorker;
late bool _isEmailBodyLoaded;

ComposerController(
Expand Down Expand Up @@ -267,7 +266,6 @@ class ComposerController extends BaseController with DragDropFileMixin {
ccEmailAddressController.dispose();
bccEmailAddressController.dispose();
uploadInlineImageWorker.dispose();
dashboardViewStateWorker.dispose();
scrollController.dispose();
scrollControllerEmailAddress.removeListener(_scrollControllerEmailAddressListener);
scrollControllerEmailAddress.dispose();
Expand Down
Loading