fixes
This commit is contained in:
@@ -75,8 +75,18 @@ pub struct App {
|
||||
pub leave_group_confirmation_step: u8,
|
||||
/// Информация профиля для отображения
|
||||
pub profile_info: Option<crate::tdlib::ProfileInfo>,
|
||||
// Reaction picker mode
|
||||
/// Режим выбора реакции
|
||||
pub is_reaction_picker_mode: bool,
|
||||
/// ID сообщения для добавления реакции
|
||||
pub selected_message_for_reaction: Option<i64>,
|
||||
/// Список доступных реакций
|
||||
pub available_reactions: Vec<String>,
|
||||
/// Индекс выбранной реакции в picker
|
||||
pub selected_reaction_index: usize,
|
||||
}
|
||||
|
||||
|
||||
impl App {
|
||||
pub fn new() -> App {
|
||||
let mut state = ListState::default();
|
||||
@@ -119,6 +129,10 @@ impl App {
|
||||
selected_profile_action: 0,
|
||||
leave_group_confirmation_step: 0,
|
||||
profile_info: None,
|
||||
is_reaction_picker_mode: false,
|
||||
selected_message_for_reaction: None,
|
||||
available_reactions: Vec::new(),
|
||||
selected_reaction_index: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,4 +620,44 @@ impl App {
|
||||
pub fn get_leave_group_confirmation_step(&self) -> u8 {
|
||||
self.leave_group_confirmation_step
|
||||
}
|
||||
|
||||
// ========== Reaction Picker ==========
|
||||
|
||||
pub fn is_reaction_picker_mode(&self) -> bool {
|
||||
self.is_reaction_picker_mode
|
||||
}
|
||||
|
||||
pub fn enter_reaction_picker_mode(&mut self, message_id: i64, available_reactions: Vec<String>) {
|
||||
self.is_reaction_picker_mode = true;
|
||||
self.selected_message_for_reaction = Some(message_id);
|
||||
self.available_reactions = available_reactions;
|
||||
self.selected_reaction_index = 0;
|
||||
}
|
||||
|
||||
pub fn exit_reaction_picker_mode(&mut self) {
|
||||
self.is_reaction_picker_mode = false;
|
||||
self.selected_message_for_reaction = None;
|
||||
self.available_reactions.clear();
|
||||
self.selected_reaction_index = 0;
|
||||
}
|
||||
|
||||
pub fn select_previous_reaction(&mut self) {
|
||||
if !self.available_reactions.is_empty() && self.selected_reaction_index > 0 {
|
||||
self.selected_reaction_index -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn select_next_reaction(&mut self) {
|
||||
if self.selected_reaction_index + 1 < self.available_reactions.len() {
|
||||
self.selected_reaction_index += 1;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_selected_reaction(&self) -> Option<&String> {
|
||||
self.available_reactions.get(self.selected_reaction_index)
|
||||
}
|
||||
|
||||
pub fn get_selected_message_for_reaction(&self) -> Option<i64> {
|
||||
self.selected_message_for_reaction
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user