chore: fix crash when failing to parse message (#202)

* clean up

* .

* fix rich text component

* clean up
This commit is contained in:
reya
2025-11-03 19:04:16 +07:00
committed by GitHub
parent 4ebe590f8a
commit a4067d2c00
12 changed files with 200 additions and 366 deletions

View File

@@ -1167,42 +1167,41 @@ impl ChatSpace {
let file_keystore = KeyStore::global(cx).read(cx).is_using_file_keystore();
let proxy = AppSettings::get_proxy_user_avatars(cx);
let auth_requests = self.auth_requests.read(cx).len();
let auto_update = AutoUpdater::global(cx);
h_flex()
.gap_1()
.map(
|this| match AutoUpdater::global(cx).read(cx).status.as_ref() {
AutoUpdateStatus::Checking => this.child(
div()
.text_xs()
.text_color(cx.theme().text_muted)
.child(SharedString::from("Checking for Coop updates...")),
),
AutoUpdateStatus::Installing => this.child(
div()
.text_xs()
.text_color(cx.theme().text_muted)
.child(SharedString::from("Installing updates...")),
),
AutoUpdateStatus::Errored { msg } => this.child(
div()
.text_xs()
.text_color(cx.theme().text_muted)
.child(SharedString::from(msg.as_ref())),
),
AutoUpdateStatus::Updated => this.child(
div()
.id("restart")
.text_xs()
.text_color(cx.theme().text_muted)
.child(SharedString::from("Updated. Click to restart"))
.on_click(|_ev, _window, cx| {
cx.restart();
}),
),
_ => this.child(div()),
},
)
.map(|this| match auto_update.read(cx).status.as_ref() {
AutoUpdateStatus::Checking => this.child(
div()
.text_xs()
.text_color(cx.theme().text_muted)
.child(SharedString::from("Checking for Coop updates...")),
),
AutoUpdateStatus::Installing => this.child(
div()
.text_xs()
.text_color(cx.theme().text_muted)
.child(SharedString::from("Installing updates...")),
),
AutoUpdateStatus::Errored { msg } => this.child(
div()
.text_xs()
.text_color(cx.theme().text_muted)
.child(SharedString::from(msg.as_ref())),
),
AutoUpdateStatus::Updated => this.child(
div()
.id("restart")
.text_xs()
.text_color(cx.theme().text_muted)
.child(SharedString::from("Updated. Click to restart"))
.on_click(|_ev, _window, cx| {
cx.restart();
}),
),
_ => this.child(div()),
})
.when(file_keystore, |this| {
this.child(
Button::new("keystore-warning")

View File

@@ -6,7 +6,7 @@ use gpui::{
TitlebarOptions, WindowBackgroundAppearance, WindowBounds, WindowDecorations, WindowKind,
WindowOptions,
};
use states::{app_state, APP_ID, CLIENT_NAME};
use states::{app_state, APP_ID, BOOTSTRAP_RELAYS, CLIENT_NAME, SEARCH_RELAYS};
use ui::Root;
use crate::actions::{load_embedded_fonts, quit, Quit};
@@ -21,14 +21,34 @@ fn main() {
// Initialize logging
tracing_subscriber::fmt::init();
// Initialize the coop simple storage
let _app_state = app_state();
// Initialize the Application
let app = Application::new()
.with_assets(Assets)
.with_http_client(Arc::new(reqwest_client::ReqwestClient::new()));
// Initialize app state
let app_state = app_state();
// Connect to relays
app.background_executor()
.spawn(async move {
let client = app_state.client();
// Get all bootstrapping relays
let mut urls = vec![];
urls.extend(BOOTSTRAP_RELAYS);
urls.extend(SEARCH_RELAYS);
// Add relay to the relay pool
for url in urls.into_iter() {
client.add_relay(url).await.ok();
}
// Establish connection to relays
client.connect().await;
})
.detach();
// Run application
app.run(move |cx| {
// Load embedded fonts in assets/fonts

View File

@@ -6,7 +6,7 @@ use anyhow::{anyhow, Error};
use chat::room::{Room, RoomKind};
use chat::{ChatEvent, ChatRegistry};
use common::debounced_delay::DebouncedDelay;
use common::display::{RenderedProfile, RenderedTimestamp, TextUtils};
use common::display::{RenderedTimestamp, TextUtils};
use gpui::prelude::FluentBuilder;
use gpui::{
deferred, div, relative, uniform_list, AnyElement, App, AppContext, Context, Entity,
@@ -628,8 +628,8 @@ impl Sidebar {
items.push(
RoomListItem::new(ix)
.room_id(room_id)
.name(member.display_name())
.avatar(member.avatar(proxy))
.name(this.display_name(cx))
.avatar(this.display_image(proxy, cx))
.public_key(member.public_key())
.kind(this.kind)
.created_at(this.created_at.to_ago())