fix(frontend): account phone stored with a plus is not shown with two
This commit is contained in:
1 parent
aff8a9e443
commit
e228d999dd
4 files changed
+10
-5
No files matched your search
@@ -18,6 +18,7 @@
|
|||||||
import ProfileSection from "#lib/components/profile/ProfileSection.svelte";
|
import ProfileSection from "#lib/components/profile/ProfileSection.svelte";
|
||||||
import Icon from "#lib/components/ui/Icon.svelte";
|
import Icon from "#lib/components/ui/Icon.svelte";
|
||||||
import { formatDate, formatFull } from "#lib/format/datetime.js";
|
import { formatDate, formatFull } from "#lib/format/datetime.js";
|
||||||
|
import { formatPhone } from "#lib/format/peer.js";
|
||||||
import { t } from "#lib/i18n/locale.svelte.js";
|
import { t } from "#lib/i18n/locale.svelte.js";
|
||||||
import { accounts } from "#lib/stores/accounts.svelte.js";
|
import { accounts } from "#lib/stores/accounts.svelte.js";
|
||||||
import { peers } from "#lib/stores/peers.svelte.js";
|
import { peers } from "#lib/stores/peers.svelte.js";
|
||||||
@@ -56,7 +57,7 @@
|
|||||||
result.push({
|
result.push({
|
||||||
icon: "phone",
|
icon: "phone",
|
||||||
label: t("profile.phone"),
|
label: t("profile.phone"),
|
||||||
value: `+${peer.phone}`,
|
value: formatPhone(peer.phone),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (peer?.username) {
|
if (peer?.username) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
import Avatar from "#lib/components/ui/Avatar.svelte";
|
import Avatar from "#lib/components/ui/Avatar.svelte";
|
||||||
import EmptyState from "#lib/components/ui/EmptyState.svelte";
|
import EmptyState from "#lib/components/ui/EmptyState.svelte";
|
||||||
import Icon from "#lib/components/ui/Icon.svelte";
|
import Icon from "#lib/components/ui/Icon.svelte";
|
||||||
import { peerName } from "#lib/format/peer.js";
|
import { formatPhone, peerName } from "#lib/format/peer.js";
|
||||||
import { t } from "#lib/i18n/locale.svelte.js";
|
import { t } from "#lib/i18n/locale.svelte.js";
|
||||||
import type { MessageKey } from "#lib/i18n/messages.js";
|
import type { MessageKey } from "#lib/i18n/messages.js";
|
||||||
import { accounts } from "#lib/stores/accounts.svelte.js";
|
import { accounts } from "#lib/stores/accounts.svelte.js";
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
if (peer?.username) {
|
if (peer?.username) {
|
||||||
return `@${peer.username}`;
|
return `@${peer.username}`;
|
||||||
}
|
}
|
||||||
return peer?.phone ? `+${peer.phone}` : `ID ${targetId}`;
|
return peer?.phone ? formatPhone(peer.phone) : `ID ${targetId}`;
|
||||||
}
|
}
|
||||||
const count = chat?.message_count ?? 0;
|
const count = chat?.message_count ?? 0;
|
||||||
return count > 0 ? t("profile.messages", { count }) : t("profile.group");
|
return count > 0 ? t("profile.messages", { count }) : t("profile.group");
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import SettingsItem from "#lib/components/settings/SettingsItem.svelte";
|
import SettingsItem from "#lib/components/settings/SettingsItem.svelte";
|
||||||
import Button from "#lib/components/ui/Button.svelte";
|
import Button from "#lib/components/ui/Button.svelte";
|
||||||
import Icon from "#lib/components/ui/Icon.svelte";
|
import Icon from "#lib/components/ui/Icon.svelte";
|
||||||
import { accountName } from "#lib/format/peer.js";
|
import { accountName, formatPhone } from "#lib/format/peer.js";
|
||||||
import { t } from "#lib/i18n/locale.svelte.js";
|
import { t } from "#lib/i18n/locale.svelte.js";
|
||||||
import { accounts } from "#lib/stores/accounts.svelte.js";
|
import { accounts } from "#lib/stores/accounts.svelte.js";
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
<AccountAvatar account={current} size={5} />
|
<AccountAvatar account={current} size={5} />
|
||||||
<div class="name">{accountName(current)}</div>
|
<div class="name">{accountName(current)}</div>
|
||||||
{#if current.phone}
|
{#if current.phone}
|
||||||
<div class="phone">+{current.phone}</div>
|
<div class="phone">{formatPhone(current.phone)}</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if !current.is_active}
|
{#if !current.is_active}
|
||||||
<div class="inactive">{t("account.inactive")}</div>
|
<div class="inactive">{t("account.inactive")}</div>
|
||||||
|
|||||||
@@ -47,3 +47,7 @@ export function initials(name: string): string {
|
|||||||
const last = lastWord ? lastWord[0] : "";
|
const last = lastWord ? lastWord[0] : "";
|
||||||
return (first + last).toUpperCase();
|
return (first + last).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatPhone(phone: string): string {
|
||||||
|
return phone.startsWith("+") ? phone : `+${phone}`;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user