UBERF-10248: Fix local time (#8623)

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko 2025-04-18 13:09:08 +07:00 committed by GitHub
parent cb9a0d5017
commit 7575fa08ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 59 additions and 51 deletions

View File

@ -111,7 +111,6 @@
"ViberPlaceholder": "Viber",
"UserProfile": "Uživatelský profil",
"DeactivatedAccount": "Deaktivovaný účet",
"LocalTime": "místní čas",
"LocalTimeNotSet": "Místní čas není nastaven"
"LocalTime": "místní čas"
}
}

View File

@ -111,7 +111,6 @@
"ViberPlaceholder": "Viber",
"UserProfile": "Benutzerprofil",
"DeactivatedAccount": "Deaktivierter Account",
"LocalTime": "Ortszeit",
"LocalTimeNotSet": "Ortszeit nicht festgelegt"
"LocalTime": "Ortszeit"
}
}

View File

@ -115,7 +115,6 @@
"Confirmed": "Confirmed",
"UserProfile": "User profile",
"DeactivatedAccount": "Deactivated account",
"LocalTime": "local time",
"LocalTimeNotSet": "Local time not set"
"LocalTime": "local time"
}
}

View File

@ -115,7 +115,6 @@
"Confirmed": "Confirmado",
"UserProfile": "Perfil de usuario",
"DeactivatedAccount": "Cuenta desactivada",
"LocalTime": "hora local",
"LocalTimeNotSet": "Hora local no establecida"
"LocalTime": "hora local"
}
}

View File

@ -115,7 +115,6 @@
"Confirmed": "Confirmé",
"UserProfile": "Profil utilisateur",
"DeactivatedAccount": "Compte désactivé",
"LocalTime": "heure locale",
"LocalTimeNotSet": "Heure locale non définie"
"LocalTime": "heure locale"
}
}

View File

@ -115,7 +115,6 @@
"Confirmed": "Confermato",
"UserProfile": "Profilo utente",
"DeactivatedAccount": "Account disattivato",
"LocalTime": "ora locale",
"LocalTimeNotSet": "Ora locale non impostata"
"LocalTime": "ora locale"
}
}

View File

@ -115,7 +115,6 @@
"Confirmed": "Confirmado",
"UserProfile": "Perfil do usuário",
"DeactivatedAccount": "Conta desativada",
"LocalTime": "hora local",
"LocalTimeNotSet": "Hora local não definida"
"LocalTime": "hora local"
}
}

View File

@ -115,7 +115,6 @@
"Confirmed": "Подтвержден",
"UserProfile": "Профиль пользователя",
"DeactivatedAccount": "Деактивированный аккаунт",
"LocalTime": "местного времени",
"LocalTimeNotSet": "Местное время не задано"
"LocalTime": "местного времени"
}
}

View File

@ -115,7 +115,6 @@
"Confirmed": "已确认",
"UserProfile": "用户资料",
"DeactivatedAccount": "已停用账户",
"LocalTime": "当地时间",
"LocalTimeNotSet": "未设置当地时间"
"LocalTime": "当地时间"
}
}

View File

@ -23,7 +23,8 @@
import ModernProfilePopup from './ModernProfilePopup.svelte'
import contact from '../../plugin'
import Avatar from '../Avatar.svelte'
import { employeeByIdStore, getAccountClient } from '../../utils'
import { employeeByIdStore } from '../../utils'
import { getPersonTimezone } from './utils'
import { EmployeePresenter } from '../../index'
import TimePresenter from './TimePresenter.svelte'
import DeactivatedHeader from './DeactivatedHeader.svelte'
@ -36,7 +37,6 @@
let employee: Employee | undefined = undefined
let timezone: string | undefined = undefined
let isTimezoneLoading = true
$: employee = $employeeByIdStore.get(_id)
$: void loadPersonTimezone(employee?.personUuid)
@ -50,15 +50,7 @@
}
async function loadPersonTimezone (personId: AccountUuid | undefined): Promise<void> {
if (personId === undefined) return
isTimezoneLoading = true
try {
const accountInfo = await getAccountClient().getAccountInfo(personId)
timezone = accountInfo.timezone
} catch (error) {
console.error(error)
}
isTimezoneLoading = false
timezone = await getPersonTimezone(personId)
}
</script>
@ -95,9 +87,10 @@
on:click={viewProfile}
/>
<div class="flex-col flex-gap-0-5">
<div class="status-container" />
<EmployeePresenter value={employee} shouldShowAvatar={false} showPopup={false} compact accent />
<span class="flex-presenter cursor-default">
<TimePresenter {timezone} {isTimezoneLoading} />
<TimePresenter {timezone} />
</span>
</div>
</div>
@ -151,4 +144,8 @@
display: flex;
background-color: var(--theme-button-container-color);
}
.status-container {
display: flex;
min-height: 1rem;
}
</style>

View File

@ -13,13 +13,11 @@
// limitations under the License.
-->
<script lang="ts">
import { Icon, Label } from '@hcengineering/ui'
import { Label } from '@hcengineering/ui'
import contact from '@hcengineering/contact'
import view from '@hcengineering/view'
export let timezone: string | undefined
export let isTimezoneLoading: boolean
function displayTimeInTimezone (timezone: string): string {
const options: Intl.DateTimeFormatOptions = {
@ -35,30 +33,19 @@
</script>
<div class="time-container">
<div class="clock-icon">
<Icon icon={contact.icon.Clock} size={'smaller'} />
</div>
<div class="text-normal font-normal content-color select-text">
{#if isTimezoneLoading}
<span class="time-text-span"><Label label={view.string.Loading} /></span>
{:else if timezone != null}
<div class="text-normal font-normal content-color">
{#if timezone != null}
<span class="time-text-span">{displayTimeInTimezone(timezone)} <Label label={contact.string.LocalTime} /></span>
{:else}
<span class="time-text-span"><Label label={contact.string.LocalTimeNotSet} /></span>
{/if}
</div>
</div>
<style>
.clock-icon {
position: relative;
color: var(--theme-content-color);
}
.time-container {
justify-content: flex-start;
align-items: center;
gap: 0.25rem;
display: inline-flex;
min-height: 1.25rem;
}
</style>

View File

@ -10,12 +10,16 @@
//
// See the License for the specific language governing permissions and
// limitations under the License.
import { get, writable } from 'svelte/store'
import type { AccountUuid, Class, Ref } from '@hcengineering/core'
import type { Person } from '@hcengineering/contact'
import { getClient } from '@hcengineering/presentation'
import type { LabelAndProps } from '@hcengineering/ui'
import contact from '../../plugin'
import EmployeePreviewPopup from './EmployeePreviewPopup.svelte'
import type { Class, Ref } from '@hcengineering/core'
import { getAccountClient } from '../../utils'
const client = getClient()
const h = client.getHierarchy()
@ -35,3 +39,28 @@ export function getPreviewPopup (
noArrow: true
}
}
export const timezoneByAccountStore = writable<Map<AccountUuid, string>>(new Map())
export async function getPersonTimezone (personId: AccountUuid | undefined): Promise<string | undefined> {
if (personId === undefined) return undefined
const storedTimezone = get(timezoneByAccountStore).get(personId)
if (storedTimezone !== undefined) return storedTimezone
try {
const accountInfo = await getAccountClient().getAccountInfo(personId)
if (accountInfo.timezone !== undefined) {
timezoneByAccountStore.update((store: Map<AccountUuid, string>) => {
if (accountInfo.timezone !== undefined) {
store.set(personId, accountInfo.timezone)
}
return store
})
}
return accountInfo.timezone
} catch (error) {
console.error(error)
return undefined
}
}

View File

@ -336,8 +336,7 @@ export const contactPlugin = plugin(contactId, {
Confirmed: '' as IntlString,
UserProfile: '' as IntlString,
DeactivatedAccount: '' as IntlString,
LocalTime: '' as IntlString,
LocalTimeNotSet: '' as IntlString
LocalTime: '' as IntlString
},
viewlet: {
TableMember: '' as Ref<Viewlet>,

View File

@ -527,7 +527,8 @@ export async function selectWorkspace (
workspaceUrl: string
kind: 'external' | 'internal' | 'byregion'
externalRegions?: string[]
}
},
meta?: Meta
): Promise<WorkspaceLoginInfo> {
const { workspaceUrl, kind, externalRegions = [] } = params
const { account: accountUuid, workspace: tokenWorkspaceUuid, extra } = decodeTokenVerbose(ctx, token ?? '')
@ -581,6 +582,10 @@ export async function selectWorkspace (
throw new PlatformError(new Status(Severity.ERROR, platform.status.WorkspaceNotFound, { workspaceUrl }))
}
if (accountUuid !== systemAccountUuid) {
void setTimezoneIfNotDefined(ctx, db, accountUuid, account, meta)
}
if (accountUuid === systemAccountUuid || extra?.admin === 'true') {
return {
account: accountUuid,