fix(ui): per-bot invite caption + friendly self-redeem note
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 12s
CI / ui (pull_request) Successful in 47s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 57s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 12s
CI / ui (pull_request) Successful in 47s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 57s
- The share caption is now in the bot's language: 'Давай играть в Эрудит!' (ru bot), "Let's play Scrabble!" (en bot) — picked by the session service language, not the interface language. - Redeeming your own invite (deep link or manual) no longer shows the scary 'can't do that to yourself' error; it shows a friendly neutral note instead.
This commit is contained in:
@@ -493,7 +493,13 @@ async function routeStartParam(param: string): Promise<void> {
|
|||||||
showToast(t('friends.added', { name: friend.displayName }));
|
showToast(t('friends.added', { name: friend.displayName }));
|
||||||
void refreshNotifications();
|
void refreshNotifications();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
handleError(err);
|
// Tapping your own invite link redeems your own code: show a friendly note, not
|
||||||
|
// the scary "can't do that to yourself" error.
|
||||||
|
if (err instanceof GatewayError && err.code === 'self_relation') {
|
||||||
|
showToast(t('friends.selfInvite'));
|
||||||
|
} else {
|
||||||
|
handleError(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -234,8 +234,9 @@ export const en = {
|
|||||||
'friends.copy': 'Copy',
|
'friends.copy': 'Copy',
|
||||||
'friends.codeCopied': 'Code copied.',
|
'friends.codeCopied': 'Code copied.',
|
||||||
'friends.shareTelegram': 'Share via Telegram',
|
'friends.shareTelegram': 'Share via Telegram',
|
||||||
'friends.inviteText': "Let's be friends in Scrabble!",
|
'friends.inviteText': "Let's play Scrabble!",
|
||||||
'friends.linkCopied': 'Link copied.',
|
'friends.linkCopied': 'Link copied.',
|
||||||
|
'friends.selfInvite': "Hopefully you've been friends with yourself for a while ☺️",
|
||||||
'friends.added': 'Added {name}.',
|
'friends.added': 'Added {name}.',
|
||||||
'friends.blockedList': 'Blocked players',
|
'friends.blockedList': 'Blocked players',
|
||||||
'friends.unblock': 'Unblock',
|
'friends.unblock': 'Unblock',
|
||||||
|
|||||||
@@ -235,8 +235,9 @@ export const ru: Record<MessageKey, string> = {
|
|||||||
'friends.copy': 'Копировать',
|
'friends.copy': 'Копировать',
|
||||||
'friends.codeCopied': 'Код скопирован.',
|
'friends.codeCopied': 'Код скопирован.',
|
||||||
'friends.shareTelegram': 'Поделиться через Telegram',
|
'friends.shareTelegram': 'Поделиться через Telegram',
|
||||||
'friends.inviteText': 'Давай дружить в Скрэббл!',
|
'friends.inviteText': 'Давай играть в Эрудит!',
|
||||||
'friends.linkCopied': 'Ссылка скопирована.',
|
'friends.linkCopied': 'Ссылка скопирована.',
|
||||||
|
'friends.selfInvite': 'Надеюсь, что с собой Вы уже давно дружите ☺️',
|
||||||
'friends.added': 'Добавлен(а) {name}.',
|
'friends.added': 'Добавлен(а) {name}.',
|
||||||
'friends.blockedList': 'Заблокированные',
|
'friends.blockedList': 'Заблокированные',
|
||||||
'friends.unblock': 'Разблокировать',
|
'friends.unblock': 'Разблокировать',
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
import { app, handleError, refreshNotifications, showToast } from '../lib/app.svelte';
|
import { app, handleError, refreshNotifications, showToast } from '../lib/app.svelte';
|
||||||
import { connection } from '../lib/connection.svelte';
|
import { connection } from '../lib/connection.svelte';
|
||||||
import { gateway } from '../lib/gateway';
|
import { gateway } from '../lib/gateway';
|
||||||
import { t } from '../lib/i18n/index.svelte';
|
import { GatewayError } from '../lib/client';
|
||||||
|
import { localeFrom, t } from '../lib/i18n/index.svelte';
|
||||||
|
import { translate } from '../lib/i18n/catalog';
|
||||||
import { friendCodeParam, shareLink } from '../lib/deeplink';
|
import { friendCodeParam, shareLink } from '../lib/deeplink';
|
||||||
import { shareTelegramLink } from '../lib/telegram';
|
import { shareTelegramLink } from '../lib/telegram';
|
||||||
import type { AccountRef, FriendCode } from '../lib/model';
|
import type { AccountRef, FriendCode } from '../lib/model';
|
||||||
@@ -62,7 +64,11 @@
|
|||||||
showToast(t('friends.added', { name: friend.displayName }));
|
showToast(t('friends.added', { name: friend.displayName }));
|
||||||
await load();
|
await load();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError(e);
|
if (e instanceof GatewayError && e.code === 'self_relation') {
|
||||||
|
showToast(t('friends.selfInvite')); // redeeming your own code: a friendly, non-error note
|
||||||
|
} else {
|
||||||
|
handleError(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +89,10 @@
|
|||||||
// shareInvite shares the friend-code deep link: inside Telegram via the native
|
// shareInvite shares the friend-code deep link: inside Telegram via the native
|
||||||
// "share to chat" picker; on the web via the system share sheet; failing both, it
|
// "share to chat" picker; on the web via the system share sheet; failing both, it
|
||||||
// copies the link to the clipboard.
|
// copies the link to the clipboard.
|
||||||
async function shareInvite(url: string) {
|
async function shareInvite(url: string, lang: string) {
|
||||||
const text = t('friends.inviteText');
|
// The caption is in the bot's language (Эрудит for ru, Scrabble for en), not the
|
||||||
|
// interface language — the recipient lands in that bot.
|
||||||
|
const text = translate(localeFrom(lang), 'friends.inviteText');
|
||||||
if (shareTelegramLink(url, text)) return;
|
if (shareTelegramLink(url, text)) return;
|
||||||
if (typeof navigator !== 'undefined' && navigator.share) {
|
if (typeof navigator !== 'undefined' && navigator.share) {
|
||||||
try {
|
try {
|
||||||
@@ -120,7 +128,8 @@
|
|||||||
<button class="btn" onclick={redeem} disabled={!connection.online}>{t('friends.redeem')}</button>
|
<button class="btn" onclick={redeem} disabled={!connection.online}>{t('friends.redeem')}</button>
|
||||||
</div>
|
</div>
|
||||||
{#if code}
|
{#if code}
|
||||||
{@const tg = shareLink(friendCodeParam(code.code), app.session?.serviceLanguage || app.locale)}
|
{@const lang = app.session?.serviceLanguage || app.locale}
|
||||||
|
{@const tg = shareLink(friendCodeParam(code.code), lang)}
|
||||||
<div class="code" data-testid="friend-code">
|
<div class="code" data-testid="friend-code">
|
||||||
<div class="coderow">
|
<div class="coderow">
|
||||||
<button class="codeval" onclick={copyCode}>{code.code}</button>
|
<button class="codeval" onclick={copyCode}>{code.code}</button>
|
||||||
@@ -130,7 +139,7 @@
|
|||||||
{t('friends.codeHint')} · {t('friends.codeExpires', { time: codeTime(code.expiresAtUnix) })}
|
{t('friends.codeHint')} · {t('friends.codeExpires', { time: codeTime(code.expiresAtUnix) })}
|
||||||
</span>
|
</span>
|
||||||
{#if tg}
|
{#if tg}
|
||||||
<button type="button" class="link tgshare" onclick={() => shareInvite(tg)}>{t('friends.shareTelegram')}</button>
|
<button type="button" class="link tgshare" onclick={() => shareInvite(tg, lang)}>{t('friends.shareTelegram')}</button>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
|
|||||||
Reference in New Issue
Block a user