Skip to content

Commit

Permalink
Fix reply message (tdlib infers chat_id)
Browse files Browse the repository at this point in the history
Signed-off-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
  • Loading branch information
FedericoBruzzone committed Aug 2, 2024
1 parent b82fcbf commit 609f9eb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/prompt_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ impl Input {
.send(Event::SendMessage(
self.text_to_string(),
Some(TdMessageReplyToMessage {
chat_id: app_context.tg_context().open_chat_id(),
chat_id: 0, // This must be 0 and not `app_context.tg_context().open_chat_id()` because the tdlib (maybe from the version 1.8.29 or before) is able to know the chat id from the message_id; it will infer the chat id from the message_id.
message_id,
}),
))
Expand Down
8 changes: 6 additions & 2 deletions src/tg/message_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ impl MessageEntry {
content_style: Style,
wrap_width: i32,
) -> Text {
tracing::info!("Message content: {:?}", self.message_content_to_string());
tracing::info!("Reply to: {:?}", self.reply_to);
let reply_text = match &self.reply_to {
Some(reply_to) => match reply_to {
TdMessageReplyTo::Message(message) => {
Expand Down Expand Up @@ -118,10 +120,12 @@ impl MessageEntry {
.iter()
.find(|m| m.id() == message.message_id)
{
Some(m) => m.get_lines_styled_with_style(
Some(m) => {
tracing::info!("Reply to: {:?}", m.message_content_to_string());
m.get_lines_styled_with_style(
app_context.style_chat_message_reply_content(),
wrap_width,
),
)},
None => vec![Line::from("")],
},
);
Expand Down
1 change: 1 addition & 0 deletions src/tg/tg_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl TgContext {
*self.event_tx() = Some(event_tx);
}

// This is used to know if a message is being replied to.
pub fn set_reply_message(&self, message_id: i64, text: String) {
self.reply_message_id.store(message_id, Ordering::Relaxed);
*self.reply_message_text.lock().unwrap() = text;
Expand Down

0 comments on commit 609f9eb

Please sign in to comment.