-
Notifications
You must be signed in to change notification settings - Fork 9
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""modify subscribers table | ||
|
||
Revision ID: 330fdd8cd0f8 | ||
Revises: 4a15d01919b8 | ||
Create Date: 2025-02-11 12:54:51.256163 | ||
|
||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from appointment.database.models import TimeMode | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '330fdd8cd0f8' | ||
down_revision = '16c0299eff23' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.alter_column('subscribers', 'time_mode', default=TimeMode.h12) | ||
|
||
|
||
def downgrade() -> None: | ||
op.alter_column('subscribers', 'time_mode', default=TimeMode.h24) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,9 @@ | |
const browserPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; | ||
|
||
if ( | ||
(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)) | ||
Comment on lines
-14
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imo, we should remove this and just default to system. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, I can remove that. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
) { | ||
document.documentElement.classList.add('dark'); | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ import { Ref } from 'vue'; | |
import { i18nType } from '@/composables/i18n'; | ||
import { | ||
CustomEventData, Coloring, EventPopup, HTMLElementEvent, CalendarEvent, PydanticException, | ||
} from './models'; | ||
User, | ||
} from '@/models'; | ||
|
||
/** | ||
* Lowercases the first character of a string | ||
|
@@ -80,9 +81,9 @@ export const download = (data: BlobPart, filename: string, contenttype: string = | |
// This functions works independent from Pinia stores so that | ||
// it can be called even if stores are not initialized yet. | ||
export const timeFormat = (): string => { | ||
const user = JSON.parse(localStorage?.getItem('tba/user') ?? '{}'); | ||
const is12HourTime = Intl.DateTimeFormat().resolvedOptions().hour12 ? 12 : 24; | ||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The actual fix. A typo. What else. 😅 |
||
return format === 24 ? 'HH:mm' : 'hh:mm A'; | ||
}; | ||
|
||
|
@@ -91,7 +92,7 @@ export const timeFormat = (): string => { | |
// This functions works independent from Pinia stores so that | ||
// it can be called even if stores are not initialized yet. | ||
export const defaultLocale = () => { | ||
const user = JSON.parse(localStorage?.getItem('tba/user') ?? '{}'); | ||
const user = JSON.parse(localStorage?.getItem('tba/user') ?? '{}') as User; | ||
return user?.settings?.language ?? navigator.language.split('-')[0]; | ||
} | ||
|
||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.