[fractal/fractal-next] error: Remove matrix_error field from Error
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] error: Remove matrix_error field from Error
- Date: Thu, 30 Sep 2021 10:31:32 +0000 (UTC)
commit 41083196ea07cef9d4374e414e0acf05bb481d22
Author: Enterprisey <59171-enterprisey users noreply gitlab gnome org>
Date: Thu Sep 30 02:25:57 2021 -0700
error: Remove matrix_error field from Error
src/error.rs | 17 +----------------
src/session/room/mod.rs | 35 ++++++++++++++---------------------
src/session/room_list.rs | 1 -
3 files changed, 15 insertions(+), 38 deletions(-)
---
diff --git a/src/error.rs b/src/error.rs
index c3a94f03..1404c034 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,17 +1,13 @@
use gtk::{glib, subclass::prelude::*};
-use matrix_sdk::Error as MatrixError;
-
type WidgetBuilderFn = Box<dyn Fn(&super::Error) -> Option<gtk::Widget> + 'static>;
mod imp {
use super::*;
- use once_cell::sync::OnceCell;
use std::cell::RefCell;
#[derive(Default)]
pub struct Error {
- pub matrix_error: OnceCell<MatrixError>,
pub widget_builder: RefCell<Option<WidgetBuilderFn>>,
}
@@ -31,23 +27,12 @@ glib::wrapper! {
}
impl Error {
- pub fn new<F: Fn(&Self) -> Option<gtk::Widget> + 'static>(error: MatrixError, f: F) -> Self {
+ pub fn new<F: Fn(&Self) -> Option<gtk::Widget> + 'static>(f: F) -> Self {
let obj: Self = glib::Object::new(&[]).expect("Failed to create Error");
- obj.set_matrix_error(error);
obj.set_widget_builder(f);
obj
}
- fn set_matrix_error(&self, error: MatrixError) {
- let priv_ = imp::Error::from_instance(self);
- priv_.matrix_error.set(error).unwrap()
- }
-
- pub fn matrix_error(&self) -> &MatrixError {
- let priv_ = imp::Error::from_instance(self);
- priv_.matrix_error.get().unwrap()
- }
-
/// Set a function that builds the widget used to display this error in the UI
pub fn set_widget_builder<F: Fn(&Self) -> Option<gtk::Widget> + 'static>(&self, f: F) {
let priv_ = imp::Error::from_instance(self);
diff --git a/src/session/room/mod.rs b/src/session/room/mod.rs
index a5fb480b..175f42eb 100644
--- a/src/session/room/mod.rs
+++ b/src/session/room/mod.rs
@@ -414,7 +414,6 @@ impl Room {
Err(error) => {
error!("Couldn’t set the room category: {}", error);
let error = Error::new(
- error,
clone!(@weak obj => @default-return None, move |_| {
let error_message = gettext!(
"Failed to move <widget> from {} to {}.",
@@ -889,16 +888,13 @@ impl Room {
Ok(result) => Ok(result),
Err(error) => {
error!("Accepting invitation failed: {}", error);
- let error = Error::new(
- error,
- clone!(@strong self as room => move |_| {
- let error_message = gettext("Failed to accept invitation for <widget>. Try
again later.");
- let room_pill = Pill::new();
- room_pill.set_room(Some(room.clone()));
- let error_label = LabelWithWidgets::new(&error_message, vec![room_pill]);
- Some(error_label.upcast())
- }),
- );
+ let error = Error::new(clone!(@strong self as room => move |_| {
+ let error_message = gettext("Failed to accept invitation for <widget>. Try again
later.");
+ let room_pill = Pill::new();
+ room_pill.set_room(Some(room.clone()));
+ let error_label = LabelWithWidgets::new(&error_message, vec![room_pill]);
+ Some(error_label.upcast())
+ }));
if let Some(window) = self.session().parent_window() {
window.append_error(&error);
@@ -923,16 +919,13 @@ impl Room {
Ok(result) => Ok(result),
Err(error) => {
error!("Rejecting invitation failed: {}", error);
- let error = Error::new(
- error,
- clone!(@strong self as room => move |_| {
- let error_message = gettext("Failed to reject invitation for <widget>. Try
again later.");
- let room_pill = Pill::new();
- room_pill.set_room(Some(room.clone()));
- let error_label = LabelWithWidgets::new(&error_message, vec![room_pill]);
- Some(error_label.upcast())
- }),
- );
+ let error = Error::new(clone!(@strong self as room => move |_| {
+ let error_message = gettext("Failed to reject invitation for <widget>. Try again
later.");
+ let room_pill = Pill::new();
+ room_pill.set_room(Some(room.clone()));
+ let error_label = LabelWithWidgets::new(&error_message, vec![room_pill]);
+ Some(error_label.upcast())
+ }));
if let Some(window) = self.session().parent_window() {
window.append_error(&error);
diff --git a/src/session/room_list.rs b/src/session/room_list.rs
index e67fd247..ae860808 100644
--- a/src/session/room_list.rs
+++ b/src/session/room_list.rs
@@ -329,7 +329,6 @@ impl RoomList {
obj.pending_rooms_remove(&identifier);
error!("Joining room {} failed: {}", identifier, error);
let error = Error::new(
- matrix_sdk::Error::Http(error),
clone!(@strong obj => move |_| {
let error_message = gettext!(
"Failed to join room {}. Try again later.", identifier
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]