Skip to content

Commit 31f3ba9

Browse files
committed
fix(statusbar): remove datetime formates enum; update function to get formatted time
1 parent 70b88d2 commit 31f3ba9

File tree

6 files changed

+8
-128
lines changed

6 files changed

+8
-128
lines changed

shell/crates/status_bar/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ categories.workspace = true
1111
keywords.workspace = true
1212

1313
[dependencies]
14+
networkmanager = { workspace = true }
15+
bluez = { workspace = true }
16+
upower = { workspace = true }
17+
commons = { path = "../commons" }
1418
gpui = { workspace = true }
1519
rust-embed = { workspace = true }
1620
anyhow = { workspace = true }
17-
commons = { path = "../commons" }
1821
chrono = { version = "0.4", features = ["clock"] }
19-
networkmanager = { workspace = true }
20-
bluez = { workspace = true }
21-
upower = { workspace = true }
2222
futures = "0.3.31"

shell/crates/status_bar/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
mod ui;
22
mod events;
3-
pub mod types;
43
pub mod services;
54

65
pub mod prelude {
76
pub use crate::ui::{StatusBar, Icon, IconName};
87
pub use crate::events::AppEvents;
9-
pub use crate::types::DateTimeFormat;
108
}

shell/crates/status_bar/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ fn main() {
4545
cx.new(|cx| {
4646
cx.spawn(async move |app, cx| {
4747
while let Some(event) = app_channel_rx.next().await {
48-
println!(" IN UI AppChannel event: {:?}", event);
4948
match event {
5049
AppEvents::WirelessStatusChanged { enabled } => {
5150
let _ = app.update(cx, |this: &mut StatusBar, cx| {

shell/crates/status_bar/src/types/datetime_format.rs

Lines changed: 0 additions & 104 deletions
This file was deleted.

shell/crates/status_bar/src/types/mod.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

shell/crates/status_bar/src/ui/mod.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ use gpui::*;
33
pub mod icon;
44
pub use icon::{Icon, IconName};
55
use upower::interfaces::device::BatteryState;
6-
pub use crate::types::DateTimeFormat;
76

8-
pub fn get_current_datetime(format: DateTimeFormat) -> String {
7+
pub fn get_current_datetime() -> String {
98
let now = Local::now();
10-
format.format_datetime(&now)
9+
format!("{}", now.format("%H:%M"))
1110
}
1211

1312
pub struct StatusBar {
1413
pub current_time_date: String,
15-
pub datetime_format: DateTimeFormat,
1614
pub wireless_enabled: bool,
1715
pub wireless_strength: u8,
1816
pub bluetooth_enabled: bool,
@@ -23,10 +21,8 @@ pub struct StatusBar {
2321

2422
impl StatusBar {
2523
pub fn new() -> Self {
26-
let format = DateTimeFormat::Time12Only; // get from mxconf ?
2724
Self {
28-
current_time_date: get_current_datetime(format),
29-
datetime_format: format,
25+
current_time_date: get_current_datetime(),
3026
wireless_enabled: false,
3127
wireless_strength: 0,
3228
bluetooth_enabled: false,
@@ -36,21 +32,14 @@ impl StatusBar {
3632
}
3733
}
3834

39-
pub fn set_datetime_format(&mut self, format: DateTimeFormat, cx: &mut Context<Self>) {
40-
self.datetime_format = format;
41-
self.current_time_date = get_current_datetime(format);
42-
cx.notify();
43-
}
44-
4535
pub fn update_time(&mut self, cx: &mut Context<Self>) {
46-
self.current_time_date = get_current_datetime(self.datetime_format);
36+
self.current_time_date = get_current_datetime();
4737
cx.notify();
4838
}
4939
}
5040

5141
impl Render for StatusBar {
5242
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
53-
5443
let wireless_icon = match self.wireless_enabled {
5544
true => match self.wireless_strength {
5645
0..=20 => IconName::WirelessLow,

0 commit comments

Comments
 (0)