fix(vk): persist settings via VK Bridge storage; hide competing sign-in in Mini App hosts
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 1m28s
CI / conformance (pull_request) Successful in 16s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 2m6s
CI / changes (pull_request) Successful in 3s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 1m28s
CI / conformance (pull_request) Successful in 16s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 2m6s
VK moderation follow-ups. 1. Settings (theme, language, board style, reduce-motion, zoom, first-run coachmark flags) were lost between reloads in VK's desktop iframe: Firefox partitions/blocks IndexedDB and localStorage in a cross-origin iframe, so the browser-local store is empty on every reload (a plain tab / PWA keeps them — first-party storage — and Telegram has its own CloudStorage sync). Mirror the prefs (plus the locale, which has no other durable client home on VK) and the coachmark flags to VK Bridge storage (VKWebAppStorageSet/Get), which travels over postMessage to vk.com and survives; reconcile them on the VK launch before the first paint. The VK identity re-derives from the signed launch params each load, so the values reload onto the same account. 2. Inside a proprietary Mini App host (VK or Telegram) the profile now surfaces only email linking — both the Telegram and VK link/unlink entries are hidden (signInProvidersVisible), so a competing sign-in is never advertised (a platform ToS requirement; VK forbids showing a Telegram login, mirrored in Telegram for VK). A provider linked earlier on the web stays attached and is managed from the web; web/native builds show both. Tests: vkprefs codec + signInProvidersVisible unit tests. Docs: ARCHITECTURE, FUNCTIONAL (+_ru). No schema/wire change.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
awayMinutes,
|
||||
browserOffset,
|
||||
isOffsetZone,
|
||||
signInProvidersVisible,
|
||||
timezoneOffsets,
|
||||
validDisplayName,
|
||||
validEmail,
|
||||
@@ -67,11 +68,11 @@
|
||||
const nativeShell = clientChannel() === 'android' || clientChannel() === 'ios';
|
||||
const telegramLinkable = loginWidgetAvailable() && !nativeShell;
|
||||
const vkLinkable = vkWebLinkAvailable() && !nativeShell;
|
||||
// Inside a host Mini App the current platform's own identity must not be managed from the
|
||||
// profile — unlinking the very platform you are signed in through is meaningless — so that
|
||||
// provider's linked-account row is hidden here (the web / native builds still show both).
|
||||
const hostTelegram = insideTelegram();
|
||||
const hostVK = insideVK();
|
||||
// Inside a proprietary Mini App host (VK or Telegram) the profile shows only email linking — the
|
||||
// competing provider entries are hidden there (a platform ToS requirement; see
|
||||
// signInProvidersVisible). A provider linked earlier on the web stays linked in the account and is
|
||||
// managed from the web.
|
||||
const providersVisible = signInProvidersVisible(insideTelegram(), insideVK());
|
||||
|
||||
function defaultTz(): string {
|
||||
const b = browserOffset();
|
||||
@@ -429,9 +430,9 @@
|
||||
|
||||
<!-- Sign-in methods: bind/change an email and link/unlink providers. A returning email
|
||||
(add) triggers the merge dialog below. On the web an account can add Telegram via the
|
||||
login widget or VK via VK ID web login (a full-page redirect); inside a Mini App the
|
||||
host provider is already linked, so its own row is hidden — the platform you are signed
|
||||
in through cannot be unlinked from here (the other provider's row still shows). Email is
|
||||
login widget or VK via VK ID web login (a full-page redirect). Inside a proprietary Mini
|
||||
App host (VK or Telegram) only email is offered — both provider rows and Link buttons are
|
||||
hidden (signInProvidersVisible), a ToS requirement not to surface a competing sign-in there. Email is
|
||||
never unlinked — it is changed. Unlink is offered only when another identity remains
|
||||
(the backend also refuses the last one). -->
|
||||
<section class="accounts">
|
||||
@@ -480,30 +481,32 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if p.telegramLinked && !hostTelegram}
|
||||
<div class="acctrow">
|
||||
<span class="prov"><img src="telegram-logo.svg" alt="" width="18" height="18" />Telegram</span>
|
||||
{#if canUnlink}
|
||||
<button class="ghost danger" onclick={() => (confirmUnlink = { kind: 'telegram', label: 'Telegram' })} disabled={!connection.online}>{t('profile.unlink')}</button>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if telegramLinkable}
|
||||
<button class="ghost tg" onclick={linkTelegram} disabled={!connection.online}>
|
||||
<img src="telegram-logo.svg" alt="" width="18" height="18" />{t('profile.linkTelegram')}
|
||||
</button>
|
||||
{/if}
|
||||
{#if providersVisible}
|
||||
{#if p.telegramLinked}
|
||||
<div class="acctrow">
|
||||
<span class="prov"><img src="telegram-logo.svg" alt="" width="18" height="18" />Telegram</span>
|
||||
{#if canUnlink}
|
||||
<button class="ghost danger" onclick={() => (confirmUnlink = { kind: 'telegram', label: 'Telegram' })} disabled={!connection.online}>{t('profile.unlink')}</button>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if telegramLinkable}
|
||||
<button class="ghost tg" onclick={linkTelegram} disabled={!connection.online}>
|
||||
<img src="telegram-logo.svg" alt="" width="18" height="18" />{t('profile.linkTelegram')}
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if p.vkLinked && !hostVK}
|
||||
<div class="acctrow">
|
||||
<span class="prov"><img src="vk-logo.svg" alt="" width="18" height="18" />VK</span>
|
||||
{#if canUnlink}
|
||||
<button class="ghost danger" onclick={() => (confirmUnlink = { kind: 'vk', label: 'VK' })} disabled={!connection.online}>{t('profile.unlink')}</button>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if vkLinkable}
|
||||
<button class="ghost tg" onclick={addVK} disabled={!connection.online}>
|
||||
<img src="vk-logo.svg" alt="" width="18" height="18" />{t('profile.linkVK')}
|
||||
</button>
|
||||
{#if p.vkLinked}
|
||||
<div class="acctrow">
|
||||
<span class="prov"><img src="vk-logo.svg" alt="" width="18" height="18" />VK</span>
|
||||
{#if canUnlink}
|
||||
<button class="ghost danger" onclick={() => (confirmUnlink = { kind: 'vk', label: 'VK' })} disabled={!connection.online}>{t('profile.unlink')}</button>
|
||||
{/if}
|
||||
</div>
|
||||
{:else if vkLinkable}
|
||||
<button class="ghost tg" onclick={addVK} disabled={!connection.online}>
|
||||
<img src="vk-logo.svg" alt="" width="18" height="18" />{t('profile.linkVK')}
|
||||
</button>
|
||||
{/if}
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user