Skip to content

Commit

Permalink
Merge pull request #53
Browse files Browse the repository at this point in the history
Update user table handling
  • Loading branch information
TheRustyPickle authored Feb 10, 2024
2 parents 7b2ade4 + c99fe27 commit 06f361c
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 177 deletions.
2 changes: 1 addition & 1 deletion src/tg_handler/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl TGClient {
let mut start_at = if let Some(num) = start_num { num } else { -1 };

info!(
"Staring message num {}, ending message num {}",
"Starting message num {}, ending message num {}",
start_at, end_at
);

Expand Down
33 changes: 33 additions & 0 deletions src/ui_components/processor/states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,39 @@ impl ColumnName {
ColumnName::Whitelisted => ColumnName::Name,
}
}

pub fn get_previous(&self) -> Self {
match self {
ColumnName::Name => ColumnName::Whitelisted,
ColumnName::Username => ColumnName::Name,
ColumnName::UserID => ColumnName::Username,
ColumnName::TotalMessage => ColumnName::UserID,
ColumnName::TotalWord => ColumnName::TotalMessage,
ColumnName::TotalChar => ColumnName::TotalWord,
ColumnName::AverageWord => ColumnName::TotalChar,
ColumnName::AverageChar => ColumnName::AverageWord,
ColumnName::FirstMessageSeen => ColumnName::AverageChar,
ColumnName::LastMessageSeen => ColumnName::FirstMessageSeen,
ColumnName::Whitelisted => ColumnName::LastMessageSeen,
}
}

pub fn from_num(num: i32) -> Self {
match num {
0 => ColumnName::Name,
1 => ColumnName::Username,
2 => ColumnName::UserID,
3 => ColumnName::TotalMessage,
4 => ColumnName::TotalWord,
5 => ColumnName::TotalChar,
6 => ColumnName::AverageWord,
7 => ColumnName::AverageChar,
8 => ColumnName::FirstMessageSeen,
9 => ColumnName::LastMessageSeen,
10 => ColumnName::Whitelisted,
_ => unreachable!("Invalid enum variant for number {}", num),
}
}
}

#[derive(Default, PartialEq)]
Expand Down
4 changes: 2 additions & 2 deletions src/ui_components/processor/tg_comms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl MainWindow {
.add_user(sender, local_time_date, count_data.name());

if user_id != 0 && self.whitelist_data.is_user_whitelisted(&user_id) {
self.user_table.set_as_whitelisted(&user_id);
self.user_table.set_as_whitelisted(user_id);
}

let chart_user = {
Expand Down Expand Up @@ -249,7 +249,7 @@ impl MainWindow {
chat.seen_by,
);
self.whitelist_data.clear_text_box();
self.user_table.set_as_whitelisted(&user_id);
self.user_table.set_as_whitelisted(user_id);
self.process_state = ProcessState::AddedToWhitelist;
}
ProcessResult::ChatExists(chat_name, start_at, end_at) => {
Expand Down
Loading

0 comments on commit 06f361c

Please sign in to comment.