Skip to content

Commit

Permalink
feat: Port MessageDialogs to Adw.AlertDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
sungsphinx committed Feb 4, 2024
1 parent a342084 commit 228c5f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/components/playlist/get_add_to_playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ export class GetAddToPlaylist extends Adw.Window {
} else {
// try to provide an option to dedupe or add anyways
if (this.playlistId || this.videoIds && this.videoIds.length > 1) {
const dialog = Adw.MessageDialog.new(
window,
const dialog = Adw.AlertDialog.new(
_("Duplicates"),
_("One or more of the songs are already in your playlist"),
);
Expand All @@ -197,7 +196,7 @@ export class GetAddToPlaylist extends Adw.Window {
);
});

dialog.present();
dialog.present(window);
} else {
const toast = new Adw.Toast({
title: _("This song is already in the playlist"),
Expand Down
8 changes: 3 additions & 5 deletions src/pages/playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ export class PlaylistPage extends Adw.Bin
if (this.playlist?.editable !== true) return;

const dialog = Adw.MessageDialog.new(
this.get_window(),
_("Delete playlist"),
_("Are you sure you want to delete this playlist?"),
);
Expand Down Expand Up @@ -198,7 +197,7 @@ export class PlaylistPage extends Adw.Bin
}
});

dialog.present();
dialog.present(this.get_window());
}

private remove_tracks(positions: number[]) {
Expand Down Expand Up @@ -237,8 +236,7 @@ export class PlaylistPage extends Adw.Bin
);
};

const dialog = Adw.MessageDialog.new(
this.get_window(),
const dialog = Adw.AlertDialog.new(
_("Remove from playlist"),
_(" Are you sure that you want to remove the selected content from the playlist? "),
);
Expand Down Expand Up @@ -278,7 +276,7 @@ export class PlaylistPage extends Adw.Bin
}
});

dialog.present();
dialog.present(this.get_window());
}

private add_cb(
Expand Down
4 changes: 2 additions & 2 deletions src/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export class Window extends Adw.ApplicationWindow {
}

logout() {
const dialog = Adw.MessageDialog.new(this, _("Logout"), _("Are you sure?"));
const dialog = Adw.AlertDialog.new(_("Logout"), _("Are you sure?"));
dialog.add_response("cancel", _("Cancel"));
dialog.add_response("logout", _("Logout"));
dialog.default_response = "cancel";
Expand All @@ -288,7 +288,7 @@ export class Window extends Adw.ApplicationWindow {
}
});

dialog.present();
dialog.present(this);
}

add_toast(text: string) {
Expand Down

0 comments on commit 228c5f2

Please sign in to comment.