forge
Explore
Log in

Don't you dare go Hollow

Appearance › Show seconds (off by default) shows message times as HH:MM:SS

Browse files at this commit

a5cfbc89a740b4f0077ec2a41b80097dcf24944bAhmet Kaan GümüşParent: 09df64d
  • feat
    • Appearance › Show seconds (off by default) shows message times as HH:MM:SS
    • Settings::clock() picks the format
Show full message
✨ feat: Appearance › Show seconds (off by default) shows message times as HH:MM:SS; Settings::clock() picks the format
crates/client/lang/en/settings_page.txtmodified+1 -0
@@ -25,3 +25,4 @@ frame_rate = Frame rate
2525 codec = Codec
2626 share_audio = Share audio
2727 back_esc = Back (esc)
28+clock_seconds = Show seconds
crates/client/lang/tr/settings_page.txtmodified+1 -0
@@ -25,3 +25,4 @@ frame_rate = Kare hızı
2525 codec = Kodek
2626 share_audio = Sesi paylaş
2727 back_esc = Geri (esc)
28+clock_seconds = Saniyeleri göster
crates/client/src/gui/chat.rsmodified+6 -3
@@ -1,6 +1,5 @@
11 use super::style::{self, radius, size, space, stroke, text};
22 use super::text;
3-use crate::gui::CLOCK;
43 use crate::gui::glyph::Fill as _;
54 use crate::lang::w;
65 use std::{
@@ -1945,6 +1944,7 @@ impl Yumush {
19451944 run,
19461945 &self.chat,
19471946 self.user.as_ref(),
1947+ self.settings.clock(),
19481948 entity,
19491949 palette,
19501950 );
@@ -3570,6 +3570,7 @@ fn render_message(
35703570 run: CallRun,
35713571 chat: &Chat,
35723572 me: Option<&User>,
3573+ clock: &'static str,
35733574 entity: &Entity<Yumush>,
35743575 palette: Palette,
35753576 ) -> AnyElement {
@@ -3628,7 +3629,9 @@ fn render_message(
36283629 .min_w_0()
36293630 .hover(|style| style.bg(palette.hover))
36303631 .when(chat.engaged(message.id), |this| this.bg(palette.hover))
3631- .when(message.deleted, |this| this.text_color(palette.tokens.faint()))
3632+ .when(message.deleted, |this| {
3633+ this.text_color(palette.tokens.faint())
3634+ })
36323635 .when(first && spaced && !selecting, |this| this.mt(px(space::LG)))
36333636 .when(highlighted, |this| this.bg(palette.tokens.press()))
36343637 .when(mentioned, |this| {
@@ -3660,7 +3663,7 @@ fn render_message(
36603663 div()
36613664 .text_size(text(text::CAPTION))
36623665 .text_color(palette.muted)
3663- .child(millis_time(message.created_at, CLOCK)),
3666+ .child(millis_time(message.created_at, clock)),
36643667 ),
36653668 )
36663669 })
crates/client/src/gui/settings_page.rsmodified+19 -1
@@ -36,7 +36,7 @@ pub(super) fn settings_titles() -> [&'static str; 4] {
3636 [w.profile, w.voice, w.camera_share, w.appearance]
3737 }
3838
39-pub(super) fn setting_rows() -> [(usize, &'static str); 23] {
39+pub(super) fn setting_rows() -> [(usize, &'static str); 24] {
4040 let s = &w().settings_page;
4141 let v = &w().voice_settings;
4242 [
@@ -62,6 +62,7 @@ pub(super) fn setting_rows() -> [(usize, &'static str); 23] {
6262 (3, s.font_size),
6363 (3, s.language),
6464 (3, s.close_to_tray),
65+ (3, s.clock_seconds),
6566 (3, s.your_hue),
6667 ]
6768 }
@@ -203,6 +204,18 @@ impl Yumush {
203204 },
204205 ),
205206 ),
207+ row(
208+ w().settings_page.clock_seconds,
209+ super::parts::toggle(
210+ "clock_seconds_switch",
211+ self.settings.clock_seconds,
212+ palette.tokens,
213+ {
214+ let entity = entity.clone();
215+ move |_, cx| entity.update(cx, |yumush, cx| yumush.toggle_clock_seconds(cx))
216+ },
217+ ),
218+ ),
206219 ];
207220 if let Some(user) = self.user.as_ref() {
208221 appearance.push(row(
@@ -376,6 +389,11 @@ impl Yumush {
376389 self.commit_settings(cx);
377390 }
378391
392+ pub(super) fn toggle_clock_seconds(&mut self, cx: &mut Context<Self>) {
393+ self.settings.clock_seconds = !self.settings.clock_seconds;
394+ self.commit_settings(cx);
395+ }
396+
379397 pub(super) fn commit_settings(&mut self, cx: &mut Context<Self>) {
380398 settings::save(&self.settings);
381399 self.network.set_voice_settings(&self.settings.voice);
crates/client/src/settings.rsmodified+15 -0
@@ -195,10 +195,21 @@ pub struct Settings {
195195 pub voice: VoiceSettings,
196196 pub share: ShareSettings,
197197 pub close_to_tray: bool,
198+ pub clock_seconds: bool,
198199 pub jump_usage: BTreeMap<String, u32>,
199200 pub last_chats: BTreeMap<Id, Id>,
200201 }
201202
203+impl Settings {
204+ pub fn clock(&self) -> &'static str {
205+ if self.clock_seconds {
206+ crate::gui::CLOCK_SECONDS
207+ } else {
208+ crate::gui::CLOCK
209+ }
210+ }
211+}
212+
202213 impl Default for Settings {
203214 fn default() -> Self {
204215 Self {
@@ -208,6 +219,7 @@ impl Default for Settings {
208219 voice: VoiceSettings::default(),
209220 share: ShareSettings::default(),
210221 close_to_tray: true,
222+ clock_seconds: false,
211223 jump_usage: BTreeMap::new(),
212224 last_chats: BTreeMap::new(),
213225 }
@@ -321,6 +333,8 @@ pub fn load() -> Settings {
321333 share,
322334 close_to_tray: text("close_to_tray")
323335 .map_or(defaults.close_to_tray, |value| value != "false"),
336+ clock_seconds: text("clock_seconds")
337+ .map_or(defaults.clock_seconds, |value| value == "true"),
324338 jump_usage: text("jump.usage")
325339 .map(|value| {
326340 value
@@ -360,6 +374,7 @@ pub fn save(settings: &Settings) {
360374 line("font_size", settings.font_size.as_str()),
361375 line("language", settings.language.as_str()),
362376 line("close_to_tray", settings.close_to_tray),
377+ line("clock_seconds", settings.clock_seconds),
363378 line("voice.sensitivity", voice.sensitivity_db),
364379 line("voice.input_volume", voice.input_volume),
365380 line("voice.output_volume", voice.output_volume),