Repository navigation
The desktop app's times keep up while it sits idle and follow the 12/24-hour setting - #241
Merged
Merged
Conversation
…24-hour setting An idle window draws itself again as each minute starts, so the chat list's relative times and the day separators move on (Today becomes Yesterday at midnight). Bubble times follow the system's 12/24-hour choice: the locale's short time on macOS, the short time format on Windows, GNOME's clock format or the locale's on Linux.
…why it failed The redraw reads the time from GPUI's scheduler clock (the system's, or in tests the test's), so the window test checks one redraw per minute start, exactly. The quoted-text tests reach the quote branch. The setting is read off the window's thread at launch; failed reads log their cause; %OI counts as a 12-hour hour; comments corrected.
Owner
Author
Review (
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Hush::observe). The time comes from GPUI's clock: the system's in the app, the test's in tests. So "Today" turns into "Yesterday" at midnight, and "14:05" into "Mon", without anything else redrawing. This matches the Mac app'sTimelineView(.everyMinute)and its midnightrefreshDays.Formatting.bubbleTime) does. The choice comes from the OS (src/clock.rs):NSDateFormatter, short time style). The formatter is made the way the Mac app makes its own, so System Settings' 24-hour switch applies to both apps alike.GetLocaleInfoEx,LOCALE_SSHORTTIME).gsettings get org.gnome.desktop.interface clock-format, because GNOME's switch sets that and not the locale. Elsewhere, or if that can't be read, the locale'sT_FMT(newlocale+nl_langinfo_l).HH 'h' mmis 24-hour.gsettings). A change shows from the next launch, as the Mac app also makes its formatter once (Formatting.cached).gsettings' exit status, or a value it doesn't know.objc2-foundation'sNSDateFormatter,windows-sys'sWin32_Globalization). It also addslibc, already in the tree, as a Linux dependency.Cargo.lockis unchanged.Kept as the Mac app has it
HH:mm(Formatting.listTime). Only bubble times follow the system clock, on the Mac and now here..everyMinutedoes. Clock times and the midnight change are on time. "Now" turns into "1m" at the first minute start after the message is 60 seconds old, as on the Mac.Shortcuts (
// shortcut:insrc/clock.rs)LC_TIME, so it is covered.How it was tested
Each new test failed before the change (checked against stubs and without the minute redraw):
an_idle_window_draws_its_times_again_as_each_minute_starts(window test). It moves the test clock to 1 ms before the next minute starts (0 redraws), then to the minute start (1), then to 1 ms before the following one (still 1), then to that start (2). Without the minute loop it drew 0 times; with a loop going by the real clock it drew 3 times in one minute.the_times_are_drawn_again_as_each_minute_starts: the wait until the next minute starts.bubble_times_read_on_the_clock_chosen: "9:05 AM", "2:30 PM", "12:00 AM", "12:15 PM" / "09:05", "14:30".a_time_pattern_says_which_clock,a_locales_time_format_says_which_clock: macOS and Windows patterns, and glibc time formats. A mutation check confirms the quoted-text cases fail without the quote handling.Gate, from
core/withCARGO_INCREMENTAL=0(all pass):cargo fmt --checkcargo clippy --all-targets -q -- -D warningscargo clippy --all-targets --features hush-desktop/snapshot -q -- -D warningscargo test --features hush-desktop/snapshot -q(295 + 537 passed)The gate was run last on the branch head after
make update; main had not moved.Also:
HH:mm, the same pattern a SwiftDateFormatter(timeStyle: .short)gives here. With-AppleLocale en_US, Swift givesh:mm a, which the parser reads as 12-hour.clippy -D warningsforx86_64-pc-windows-msvcandx86_64-unknown-linux-gnu. That was a scratch crate holding onlyclock.rs, because the whole app needs C cross-compilers for SQLCipher. They have not been run on Windows or Linux.--snapshot): looked at on this Mac's 24-hour clock (unchanged). I also rendered them once with the 12-hour clock forced, as a temporary local edit that isn't committed. "6:20 PM" fits the bubbles and the times laid over pictures; the chat list keeps "18:05".The Swift leg of
make check(xcodebuild) was skipped: nothing inapp/changes.Closes #227