Skip to content

Commit

Permalink
fix: use toasts when possible to display errors
Browse files Browse the repository at this point in the history
multiple modal on the mainwindow can lock focus
  • Loading branch information
GeopJr committed Jan 25, 2024
1 parent 9b9d6ef commit 156fe87
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Dialogs/Composer/Dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public class Tuba.Dialogs.Compose : Adw.Window {
transaction.end (res);
} catch (Error e) {
warning (e.message);
var dlg = app.inform (_("Error"), e.message);
var dlg = app.inform (_("Error"), e.message, this);
dlg.present ();
} finally {
this.sensitive = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Dialogs/ProfileEdit.vala
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class Tuba.Dialogs.ProfileEdit : Adw.Window {
on_close ();
} catch (GLib.Error e) {
critical (e.message);
var dlg = app.inform (_("Error"), e.message);
var dlg = app.inform (_("Error"), e.message, this);
dlg.present ();
} finally {
this.sensitive = true;
Expand Down
3 changes: 1 addition & 2 deletions src/Views/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ public class Tuba.Views.Sidebar : Gtk.Widget, AccountHolder {
accounts.remove (account);
} catch (Error e) {
warning (e.message);
var dlg = app.inform (_("Error"), e.message);
dlg.present ();
app.toast ("%s: %s".printf (_("Error"), e.message));
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/Views/Timeline.vala
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
if (base_status == null) {
warning (@"Error while refreshing $label: $code $reason");

var dlg = app.inform (_("Network Error"), reason);
dlg.present ();
app.toast ("%s: %s".printf (_("Network Error"), reason));
} else {
base.on_error (code, reason);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Widgets/Announcement.vala
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ public class Tuba.Widgets.Announcement : Gtk.ListBoxRow {
warning (@"Error while reacting to announcement: $code $message");
btn.sensitive = true;

var dlg = app.inform (_("Error"), message);
dlg.present ();
app.toast ("%s: %s".printf (_("Error"), message));
})
.exec ();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Widgets/Attachment/Image.vala
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public class Tuba.Widgets.Attachment.Image : Widgets.Attachment.Item {
clipboard.set_texture (texture);
app.toast (_("Copied image to clipboard"));
} catch (Error e) {
var dlg = app.inform (_("Error"), e.message);
dlg.present ();
app.toast ("%s: %s".printf (_("Error"), e.message));
}

debug ("End copy-media action");
Expand Down
3 changes: 1 addition & 2 deletions src/Widgets/Attachment/Item.vala
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ public class Tuba.Widgets.Attachment.Item : Adw.Bin {
open.end (res);
}
catch (Error e) {
var dlg = app.inform (_("Error"), e.message);
dlg.present ();
app.toast ("%s: %s".printf (_("Error"), e.message));
}
});
}
Expand Down
4 changes: 1 addition & 3 deletions src/Widgets/Status/ActionsRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,7 @@ public class Tuba.Widgets.ActionsRow : Gtk.Box {
} catch (Error e) {
warning (@"Couldn't perform action \"$action\" on a Status:");
warning (e.message);

var dlg = app.inform (_("Network Error"), e.message);
dlg.present ();
app.toast ("%s: %s".printf (_("Network Error"), e.message));

if (count_property != null)
status_btn.amount += status_btn.active ? -1 : 1;
Expand Down
3 changes: 1 addition & 2 deletions src/Widgets/VoteBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public class Tuba.Widgets.VoteBox : Gtk.Box {
button.sensitive = true;
})
.on_error ((code, reason) => {
var dlg = app.inform (_("Error"), reason);
dlg.present ();
app.toast ("%s: %s".printf (_("Error"), reason));
button.sensitive = true;
})
.exec ();
Expand Down

0 comments on commit 156fe87

Please sign in to comment.