Skip to content

Conversation

@p1gp1g
Copy link
Contributor

@p1gp1g p1gp1g commented Jan 3, 2021

Since this feature can be useful for the main version I'm PR here. It will be used on the unifiedpush branch to unregister app too

If gotify shows all messages, nothing change.
If we select an app, the right corner menu add "Delete this application" option which shows a dialog to acknowledge to delete the application.
If yes is selected it deletes the app and refresh.
else it does nothing

Copy link
Member

@jmattheis jmattheis left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, remarks in subcomments.

alert.setMessage("Are you sure?");
alert.setPositiveButton(
"YES",
new DialogInterface.OnClickListener() {
Copy link
Member

Choose a reason for hiding this comment

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

Simplify this with a lambda:

alert.setPositiveButton( "YES", (dialog, which) -> deleteApp(appId));

if (item.getItemId() == R.id.action_delete_app) {
android.app.AlertDialog.Builder alert = new android.app.AlertDialog.Builder(this);
alert.setTitle(R.string.delete_app);
alert.setMessage("Are you sure?");
Copy link
Member

Choose a reason for hiding this comment

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

This message and yes/no should be added to strings.xml.

}

private void deleteApp(Long appId) {
Thread thread =
Copy link
Member

Choose a reason for hiding this comment

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

You can use the async version of the api call instead of creating a thread for this:

private void deleteApp(Long appId) {
    ApiClient client =
            ClientFactory.clientToken(settings.url(), settings.sslSettings(), settings.token());

    client.createService(ApplicationApi.class)
            .deleteApp(appId)
            .enqueue(
                    Callback.callInUI(
                            this,
                            (ignored) -> refreshAll(),
                            (e) -> Utils.showSnackBar(this, "Could not delete app")));
}

"Could not delete app" should be put into strings.xml

@p1gp1g p1gp1g mentioned this pull request Jan 4, 2021
Copy link
Member

@jmattheis jmattheis left a comment

Choose a reason for hiding this comment

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

Thanks

@jmattheis jmattheis merged commit 107810d into gotify:master Jan 6, 2021
@p1gp1g p1gp1g deleted the master branch April 30, 2021 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants