Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12h default time format #858

Merged
merged 2 commits into from
Feb 11, 2025
Merged

Conversation

devmount
Copy link
Collaborator

Description of the Change

This PR fixes a bug, were the user setting for the time format didn't apply correctly. Also, h12 is set now as a new default.

Tip

I already took PR #854 into account for db migrations, although it is not merged yet.

Applicable Issues

Closes #850

@devmount devmount requested a review from rwood-moz February 11, 2025 13:09

# revision identifiers, used by Alembic.
revision = '330fdd8cd0f8'
down_revision = '16c0299eff23'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the last revision id from #854, so when both are merged, there shouldn't be conflicts about branching revision numbers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm running that now.

Comment on lines -14 to +16
(user?.settings?.colourScheme === 'dark'
|| (user?.settings?.colourScheme === 'system' && browserPrefersDark)
|| (!user?.settings?.colourScheme && browserPrefersDark))
(user.settings?.colourScheme === 'dark'
|| (user.settings?.colourScheme === 'system' && browserPrefersDark)
|| (!user.settings?.colourScheme && browserPrefersDark))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately we can't use TS at this place (or do we?), so we can't imply types here. But the user object is always to be expected, so I removed those first question marks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo, we should remove this and just default to system.

Copy link
Collaborator Author

@devmount devmount Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I can remove that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, actually we currently need that to apply the user settings on a fresh page reload. Also this ensures no "flashing" if the user setting differs from the system theme. I would leave it like this for now.

const format = Number(user?.setttings?.timeFormat ?? is12HourTime);
const user = JSON.parse(localStorage?.getItem('tba/user') ?? '{}') as User;
const detected = Intl.DateTimeFormat().resolvedOptions().hour12 ? 12 : 24;
const format = Number(user.settings?.timeFormat ?? detected);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual fix. A typo. What else. 😅

@devmount devmount self-assigned this Feb 11, 2025
Copy link
Contributor

@rwood-moz rwood-moz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find @devmount! \o/

Pulled the branch and tried it out, works great for me locally.

There is one frontend linting warning (it was attached automatically to your PR) or you can also see it here.

Thanks!

@devmount
Copy link
Collaborator Author

Thanks Rob!

There is one frontend linting warning (it was attached automatically to your PR) or you can also see it here.

Yes I saw that, the App.vue contains a function onPageLoad where Melissa commented out the page load metrics 6 months ago. The unused import is used in that part. @MelissaAutumn Do we still need those metrics at that place? We can for now just comment out that import and get rid of the linting warning.

Copy link
Member

@MelissaAutumn MelissaAutumn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks looks good!

Comment on lines -14 to +16
(user?.settings?.colourScheme === 'dark'
|| (user?.settings?.colourScheme === 'system' && browserPrefersDark)
|| (!user?.settings?.colourScheme && browserPrefersDark))
(user.settings?.colourScheme === 'dark'
|| (user.settings?.colourScheme === 'system' && browserPrefersDark)
|| (!user.settings?.colourScheme && browserPrefersDark))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo, we should remove this and just default to system.

@MelissaAutumn MelissaAutumn merged commit 4fef5df into main Feb 11, 2025
4 checks passed
@MelissaAutumn MelissaAutumn deleted the bugs/850-12h-default-time-format branch February 11, 2025 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time setting seems to default to 24h
3 participants