chore: improve chat panel (#121)
* . * . * . * skip sent message * improve sent reports * . * . * .
This commit is contained in:
@@ -155,12 +155,19 @@ impl ChatSpace {
|
||||
if let Some(room) = room.upgrade() {
|
||||
this.dock.update(cx, |this, cx| {
|
||||
let panel = chat::init(room, window, cx);
|
||||
// Load messages on panel creation
|
||||
|
||||
// Load messages when the panel is created
|
||||
panel.update(cx, |this, cx| {
|
||||
this.load_messages(window, cx);
|
||||
});
|
||||
|
||||
this.add_panel(panel, DockPlacement::Center, window, cx);
|
||||
// Add the panel to the center dock (tabs)
|
||||
this.add_panel(
|
||||
Arc::new(panel),
|
||||
DockPlacement::Center,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
window.push_notification(t!("common.room_error"), cx);
|
||||
|
||||
@@ -148,7 +148,7 @@ fn main() {
|
||||
|
||||
match smol::future::or(recv(), timeout()).await {
|
||||
Some(event) => {
|
||||
let cached = try_unwrap_event(&event, &signal_tx, &mta_tx).await;
|
||||
let cached = unwrap_gift(&event, &signal_tx, &mta_tx).await;
|
||||
|
||||
// Increment the total messages counter if message is not from cache
|
||||
if !cached {
|
||||
@@ -521,21 +521,21 @@ async fn get_unwrapped(root: EventId) -> Result<Event, Error> {
|
||||
}
|
||||
|
||||
/// Unwraps a gift-wrapped event and processes its contents.
|
||||
async fn try_unwrap_event(
|
||||
event: &Event,
|
||||
async fn unwrap_gift(
|
||||
gift: &Event,
|
||||
signal_tx: &Sender<NostrSignal>,
|
||||
mta_tx: &Sender<PublicKey>,
|
||||
) -> bool {
|
||||
let client = nostr_client();
|
||||
let mut is_cached = false;
|
||||
|
||||
let event = match get_unwrapped(event.id).await {
|
||||
let event = match get_unwrapped(gift.id).await {
|
||||
Ok(event) => {
|
||||
is_cached = true;
|
||||
event
|
||||
}
|
||||
Err(_) => {
|
||||
match client.unwrap_gift_wrap(event).await {
|
||||
match client.unwrap_gift_wrap(gift).await {
|
||||
Ok(unwrap) => {
|
||||
// Sign the unwrapped event with a RANDOM KEYS
|
||||
let Ok(unwrapped) = unwrap.rumor.sign_with_keys(&Keys::generate()) else {
|
||||
@@ -544,7 +544,7 @@ async fn try_unwrap_event(
|
||||
};
|
||||
|
||||
// Save this event to the database for future use.
|
||||
if let Err(e) = set_unwrapped(event.id, &unwrapped).await {
|
||||
if let Err(e) = set_unwrapped(gift.id, &unwrapped).await {
|
||||
log::warn!("Failed to cache unwrapped event: {e}")
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user