Skip to content

Throw toast when app is installed#1456

Merged
cassidyjames merged 17 commits intomasterfrom
throw-toast-when-app-is-installed
Dec 18, 2020
Merged

Throw toast when app is installed#1456
cassidyjames merged 17 commits intomasterfrom
throw-toast-when-app-is-installed

Conversation

@meisenzahl
Copy link
Copy Markdown
Member

Closes #1455

Bildschirmfoto von 2020-12-09 19-38-34

Co-authored-by: Cassidy James Blaede <cassidy@elementary.io>
@meisenzahl meisenzahl marked this pull request as ready for review December 9, 2020 19:19
@cassidyjames
Copy link
Copy Markdown
Contributor

cassidyjames commented Dec 9, 2020

Screenshot from list view

Screenshot from 2020-12-09 12-46-56

cassidyjames
cassidyjames previously approved these changes Dec 9, 2020
Copy link
Copy Markdown
Contributor

@cassidyjames cassidyjames left a comment

Choose a reason for hiding this comment

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

UX approval from me. My only open question is if it would make sense to suppress the toast on the app's own app info view (since it's redundant with the existing "Open" button that gets revealed), but that's not a blocker for me.

@cassidyjames cassidyjames requested a review from a team December 9, 2020 19:52
@meisenzahl meisenzahl marked this pull request as draft December 9, 2020 20:06
@meisenzahl
Copy link
Copy Markdown
Member Author

I will look into hiding the toast on the app's own app info view.

Copy link
Copy Markdown
Contributor

@donadigo donadigo left a comment

Choose a reason for hiding this comment

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

I have one issue.

var toast = main_window.toast;
toast.title = _("“%s” has been installed").printf (package.get_name ());

toast.send_notification ();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be better to handle sending the toast and saving the package reference inside MainWindow, instead of trying to expose last_installed_package in Application and then accessing it back in MainWindow.

Simply declare a private AppCenterCore.Package? last_installed_package member and a public void send_installed_toast (AppCenterCore.Package package) method in MainWindow and manage sending the toast there instead.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I now also need selected_package in AppCenter.App to check if a Toast should be sent.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I mean sure, but that didn't resolve my issue. The toast is still half managed in Application and MainWindow at the same time. And there's also no need to store selected_package globaly inside Application. Notice how MainWindow actually calls show_package and return_clicked where this property could be set within MainWindow as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for your feedback. I have refactored that except for selected_package.

The show_package call in MainWindow is not the same as in View.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I refactored it using a signal.

@donadigo thanks for being persistent 😃 The code looks much cleaner now 👍

@meisenzahl meisenzahl marked this pull request as ready for review December 9, 2020 20:36
Copy link
Copy Markdown
Contributor

@cassidyjames cassidyjames left a comment

Choose a reason for hiding this comment

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

Again, UX-wise this meets my approval. 😄 But I'd like to see a re-review from @elementary/desktop-developers or @donadigo.

@cassidyjames cassidyjames requested a review from a team December 9, 2020 23:10
Copy link
Copy Markdown
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

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

Just a few inline comments. Otherwise, looks pretty clean to me :)

try {
last_installed_package.launch ();
} catch (Error e) {
warning ("Failed to launch %s: %s".printf (last_installed_package.get_name (), e.message));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, I wonder if this should throw a dialog. If a user clicked the open button and then nothing happened, that seems bad. Thoughts @cassidyjames?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For reference: This code is mostly a copy from AbstractAppContainer.launch_package_app()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@danrabbit I'm indifferent. It probably makes sense to do what we do in other instances in AppCenter, and then we can file an issue to throw a dialog on failure.

donadigo
donadigo previously approved these changes Dec 18, 2020
Copy link
Copy Markdown
Contributor

@donadigo donadigo left a comment

Choose a reason for hiding this comment

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

Code looks good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Throw toast when app is installed

4 participants