fixes
This commit is contained in:
@@ -292,27 +292,27 @@ impl TdClient {
|
||||
self.message_manager.current_pinned_message = msg;
|
||||
}
|
||||
|
||||
pub fn typing_status(&self) -> Option<&(i64, String, std::time::Instant)> {
|
||||
pub fn typing_status(&self) -> Option<&(crate::types::UserId, String, std::time::Instant)> {
|
||||
self.chat_manager.typing_status.as_ref()
|
||||
}
|
||||
|
||||
pub fn set_typing_status(&mut self, status: Option<(i64, String, std::time::Instant)>) {
|
||||
pub fn set_typing_status(&mut self, status: Option<(crate::types::UserId, String, std::time::Instant)>) {
|
||||
self.chat_manager.typing_status = status;
|
||||
}
|
||||
|
||||
pub fn pending_view_messages(&self) -> &[(i64, Vec<i64>)] {
|
||||
pub fn pending_view_messages(&self) -> &[(crate::types::ChatId, Vec<crate::types::MessageId>)] {
|
||||
&self.message_manager.pending_view_messages
|
||||
}
|
||||
|
||||
pub fn pending_view_messages_mut(&mut self) -> &mut Vec<(i64, Vec<i64>)> {
|
||||
pub fn pending_view_messages_mut(&mut self) -> &mut Vec<(crate::types::ChatId, Vec<crate::types::MessageId>)> {
|
||||
&mut self.message_manager.pending_view_messages
|
||||
}
|
||||
|
||||
pub fn pending_user_ids(&self) -> &[i64] {
|
||||
pub fn pending_user_ids(&self) -> &[crate::types::UserId] {
|
||||
&self.user_cache.pending_user_ids
|
||||
}
|
||||
|
||||
pub fn pending_user_ids_mut(&mut self) -> &mut Vec<i64> {
|
||||
pub fn pending_user_ids_mut(&mut self) -> &mut Vec<crate::types::UserId> {
|
||||
&mut self.user_cache.pending_user_ids
|
||||
}
|
||||
|
||||
@@ -470,8 +470,8 @@ impl TdClient {
|
||||
let chat_id = ChatId::new(new_msg.message.chat_id);
|
||||
if Some(chat_id) == self.current_chat_id() {
|
||||
let msg_info = self.convert_message(&new_msg.message, chat_id);
|
||||
let msg_id = msg_info.id;
|
||||
let is_incoming = !msg_info.is_outgoing;
|
||||
let msg_id = msg_info.id();
|
||||
let is_incoming = !msg_info.is_outgoing();
|
||||
|
||||
// Проверяем, есть ли уже сообщение с таким id
|
||||
let existing_idx = self
|
||||
@@ -488,12 +488,12 @@ impl TdClient {
|
||||
// Для исходящих: обновляем can_be_edited и другие поля,
|
||||
// но сохраняем reply_to (добавленный при отправке)
|
||||
let existing = &mut self.current_chat_messages_mut()[idx];
|
||||
existing.can_be_edited = msg_info.can_be_edited;
|
||||
existing.can_be_deleted_only_for_self =
|
||||
msg_info.can_be_deleted_only_for_self;
|
||||
existing.can_be_deleted_for_all_users =
|
||||
msg_info.can_be_deleted_for_all_users;
|
||||
existing.is_read = msg_info.is_read;
|
||||
existing.state.can_be_edited = msg_info.state.can_be_edited;
|
||||
existing.state.can_be_deleted_only_for_self =
|
||||
msg_info.state.can_be_deleted_only_for_self;
|
||||
existing.state.can_be_deleted_for_all_users =
|
||||
msg_info.state.can_be_deleted_for_all_users;
|
||||
existing.state.is_read = msg_info.state.is_read;
|
||||
}
|
||||
}
|
||||
None => {
|
||||
@@ -518,7 +518,7 @@ impl TdClient {
|
||||
// Clone chat_user_ids to avoid borrow conflict
|
||||
let chat_user_ids = self.user_cache.chat_user_ids.clone();
|
||||
self.chats_mut()
|
||||
.retain(|c| chat_user_ids.get(&c.id) != Some(&user_id));
|
||||
.retain(|c| chat_user_ids.get(&c.id) != Some(&UserId::new(user_id)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -528,15 +528,15 @@ impl TdClient {
|
||||
} else {
|
||||
format!("{} {}", user.first_name, user.last_name)
|
||||
};
|
||||
self.user_cache.user_names.insert(user.id, display_name);
|
||||
self.user_cache.user_names.insert(UserId::new(user.id), display_name);
|
||||
|
||||
// Сохраняем username если есть
|
||||
if let Some(usernames) = user.usernames {
|
||||
if let Some(username) = usernames.active_usernames.first() {
|
||||
self.user_cache.user_usernames.insert(user.id, username.clone());
|
||||
self.user_cache.user_usernames.insert(UserId::new(user.id), username.clone());
|
||||
// Обновляем username в чатах, связанных с этим пользователем
|
||||
for (&chat_id, &user_id) in &self.user_cache.chat_user_ids.clone() {
|
||||
if user_id == user.id {
|
||||
if user_id == UserId::new(user.id) {
|
||||
if let Some(chat) = self.chats_mut().iter_mut().find(|c| c.id == chat_id)
|
||||
{
|
||||
chat.username = Some(format!("@{}", username));
|
||||
@@ -991,20 +991,20 @@ impl TdClient {
|
||||
match origin {
|
||||
MessageOrigin::User(u) => self
|
||||
.user_cache.user_names
|
||||
.peek(&u.sender_user_id)
|
||||
.peek(&UserId::new(u.sender_user_id))
|
||||
.cloned()
|
||||
.unwrap_or_else(|| format!("User_{}", u.sender_user_id)),
|
||||
MessageOrigin::Chat(c) => self
|
||||
.chats()
|
||||
.iter()
|
||||
.find(|chat| chat.id == c.sender_chat_id)
|
||||
.find(|chat| chat.id == ChatId::new(c.sender_chat_id))
|
||||
.map(|chat| chat.title.clone())
|
||||
.unwrap_or_else(|| "Чат".to_string()),
|
||||
MessageOrigin::HiddenUser(h) => h.sender_name.clone(),
|
||||
MessageOrigin::Channel(c) => self
|
||||
.chats()
|
||||
.iter()
|
||||
.find(|chat| chat.id == c.chat_id)
|
||||
.find(|chat| chat.id == ChatId::new(c.chat_id))
|
||||
.map(|chat| chat.title.clone())
|
||||
.unwrap_or_else(|| "Канал".to_string()),
|
||||
}
|
||||
@@ -1017,15 +1017,15 @@ impl TdClient {
|
||||
let msg_data: std::collections::HashMap<i64, (String, String)> = self
|
||||
.current_chat_messages()
|
||||
.iter()
|
||||
.map(|m| (m.id(), (m.sender_name().to_string(), m.text().to_string())))
|
||||
.map(|m| (m.id().as_i64(), (m.sender_name().to_string(), m.text().to_string())))
|
||||
.collect();
|
||||
|
||||
// Обновляем reply_to для сообщений с неполными данными
|
||||
for msg in self.current_chat_messages_mut().iter_mut() {
|
||||
if let Some(ref mut reply) = msg.reply_to {
|
||||
if let Some(ref mut reply) = msg.interactions.reply_to {
|
||||
// Если sender_name = "..." или text пустой — пробуем заполнить
|
||||
if reply.sender_name == "..." || reply.text.is_empty() {
|
||||
if let Some((sender, content)) = msg_data.get(&reply.message_id) {
|
||||
if let Some((sender, content)) = msg_data.get(&reply.message_id.as_i64()) {
|
||||
if reply.sender_name == "..." {
|
||||
reply.sender_name = sender.clone();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user