Skip to content

Commit 8dad721

Browse files
committed
fix various minor bugs
1 parent b1e6c66 commit 8dad721

5 files changed

Lines changed: 13 additions & 22 deletions

File tree

src/gui/pages/inspect_page.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use crate::translations::translations_2::{
3535
only_show_favorites_translation, showing_results_translation,
3636
};
3737
use crate::translations::translations_5::{only_show_blacklisted_translation, program_translation};
38+
use crate::utils::formatted_strings::clip_text;
3839
use crate::utils::types::icon::Icon;
3940
use crate::{Language, RunningPage, Sniffer, StyleType};
4041

@@ -261,16 +262,9 @@ fn row_report_entry<'a>(
261262
let max_chars = report_col.get_max_chars(None);
262263
let col_value = report_col.get_value(key, val, data_repr);
263264
ret_val = ret_val.push(
264-
Container::new(
265-
Text::new(if col_value.len() <= max_chars {
266-
col_value
267-
} else {
268-
[&col_value[..max_chars - 2], "…"].concat()
269-
})
270-
.class(text_type),
271-
)
272-
.align_x(Alignment::Center)
273-
.width(report_col.get_width()),
265+
Container::new(Text::new(clip_text(&col_value, max_chars)).class(text_type))
266+
.align_x(Alignment::Center)
267+
.width(report_col.get_width()),
274268
);
275269
}
276270
ret_val
@@ -412,7 +406,7 @@ fn filter_input<'a>(
412406

413407
let mut input = TextInput::new("", filter_value)
414408
.on_input(move |new_value| {
415-
Message::Search(filter_input_type.new_search(&search_params, new_value))
409+
Message::Search(filter_input_type.new_search(&search_params, &new_value))
416410
})
417411
.padding([2, 5])
418412
.size(FONT_SIZE_FOOTER)
@@ -462,8 +456,9 @@ fn filter_combobox(
462456

463457
let button_clear = button_clear_filter(filter_input_type.clear_search(&search_params));
464458

465-
let update_fn =
466-
move |new_value| Message::Search(filter_input_type.new_search(&search_params, new_value));
459+
let update_fn = move |new_value: String| {
460+
Message::Search(filter_input_type.new_search(&search_params, &new_value))
461+
};
467462

468463
let mut combobox = ComboBox::new(combo_box_state, "", Some(&filter_value), update_fn.clone())
469464
.on_input(update_fn)

src/networking/manage_packets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn analyze_network_header(
124124
Some(NetHeaders::Ipv6(ipv6header, _)) => {
125125
*address1 = IpAddr::from(ipv6header.source);
126126
*address2 = IpAddr::from(ipv6header.destination);
127-
*exchanged_bytes += u128::from(40 + ipv6header.payload_length);
127+
*exchanged_bytes += u128::from(ipv6header.payload_length) + 40;
128128
true
129129
}
130130
Some(NetHeaders::Arp(arp_packet)) => {

src/notifications/notify_and_log.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn notify_and_log(
4343
let notification = LoggedNotification::DataThresholdExceeded(DataThresholdExceeded {
4444
id: logged_notifications.tot(),
4545
data_repr,
46-
threshold: notifications.data_notification.previous_threshold,
46+
threshold,
4747
data_info,
4848
timestamp: get_formatted_timestamp(timestamp),
4949
is_expanded: false,

src/report/types/search_parameters.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,7 @@ impl FilterInputType {
236236
result
237237
}
238238

239-
pub fn new_search(
240-
self,
241-
search_params: &SearchParameters,
242-
new_value: String,
243-
) -> SearchParameters {
239+
pub fn new_search(self, search_params: &SearchParameters, new_value: &str) -> SearchParameters {
244240
let mut result = search_params.clone();
245241
let trimmed = new_value.trim().to_string();
246242
match self {
@@ -252,7 +248,7 @@ impl FilterInputType {
252248
FilterInputType::Service => result.service = trimmed,
253249
FilterInputType::Domain => result.domain = trimmed,
254250
FilterInputType::Country => result.country = trimmed,
255-
FilterInputType::AsName => result.as_name = new_value,
251+
FilterInputType::AsName => result.as_name = trimmed,
256252
FilterInputType::Program => result.program = trimmed,
257253
}
258254
result

src/utils/formatted_strings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub fn clip_text(text: &str, max_chars: usize) -> String {
145145

146146
let suspensions = if tot_len > max_chars { "…" } else { "" };
147147
let slice = if tot_len > max_chars {
148-
&chars[..slice_len - 2]
148+
&chars[..slice_len.saturating_sub(2)]
149149
} else {
150150
&chars[..slice_len]
151151
}

0 commit comments

Comments
 (0)