feat(vk): native share/copy, auto theme, friend-code deep link, home-bar safe area #142
@@ -751,8 +751,19 @@ async function bootVK(): Promise<void> {
|
||||
for (let attempt = 0; ; attempt++) {
|
||||
try {
|
||||
await adoptSession(await gateway.authVK(params, displayName));
|
||||
// A VK direct-link deep link (vk.com/app<id>#<param>) rides in as the `hash` launch param.
|
||||
if (!app.blocked) await routeStartParam(vkStartParam());
|
||||
// A VK direct-link deep link (vk.com/app<id>?hash=<param>) rides in as the `hash` launch param.
|
||||
const sp = vkStartParam();
|
||||
const diag = app.blocked ? 'blocked' : await routeStartParam(sp);
|
||||
// TEMP VK deep-link diagnostic (remove after the contour catch): VK launches are not
|
||||
// reproducible locally and the cold-boot path lands unexpectedly on the lobby, so surface
|
||||
// the raw query, the parsed payload, the redeem outcome and the final route.
|
||||
console.log('[VK deeplink]', {
|
||||
rawSearch: typeof location !== 'undefined' ? location.search : '',
|
||||
hash: sp,
|
||||
outcome: diag,
|
||||
route: router.route.name,
|
||||
});
|
||||
showToast(`VK dl: "${sp || '∅'}" -> ${diag}`);
|
||||
app.bootError = false;
|
||||
return;
|
||||
} catch (err) {
|
||||
@@ -814,12 +825,12 @@ export async function retryTelegramLaunch(): Promise<void> {
|
||||
* specific game, the friends screen with a friend-code redemption, or the lobby
|
||||
* (where invitations surface as a badge).
|
||||
*/
|
||||
async function routeStartParam(param: string): Promise<void> {
|
||||
async function routeStartParam(param: string): Promise<string> {
|
||||
const link = parseStartParam(param);
|
||||
switch (link.kind) {
|
||||
case 'game':
|
||||
navigate(`/game/${link.id}`);
|
||||
return;
|
||||
return 'game:' + link.id;
|
||||
case 'friendCode':
|
||||
try {
|
||||
const friend = await gateway.friendCodeRedeem(link.code);
|
||||
@@ -832,6 +843,7 @@ async function routeStartParam(param: string): Promise<void> {
|
||||
showToast(t('friends.added', { name: friend.displayName }));
|
||||
}
|
||||
void refreshNotifications();
|
||||
return 'friendCode ok: ' + friend.displayName;
|
||||
} catch (err) {
|
||||
const code = err instanceof GatewayError ? err.code : '';
|
||||
if (code === 'self_relation') {
|
||||
@@ -839,19 +851,22 @@ async function routeStartParam(param: string): Promise<void> {
|
||||
// scary "can't do that to yourself" error.
|
||||
navigate('/friends');
|
||||
showToast(t('friends.selfInvite'));
|
||||
return 'friendCode self_relation';
|
||||
} else if (code === 'friend_code_invalid') {
|
||||
// A previously shared link whose single-use, 12h code is already spent or expired:
|
||||
// land in the lobby and gently point at the bot, rather than a red error on Friends.
|
||||
navigate('/');
|
||||
app.staleInvite = true;
|
||||
return 'friendCode invalid/stale -> lobby';
|
||||
} else {
|
||||
navigate('/friends');
|
||||
handleError(err);
|
||||
return 'friendCode err: ' + (code || 'unknown');
|
||||
}
|
||||
}
|
||||
return;
|
||||
default:
|
||||
navigate('/');
|
||||
return 'lobby (empty/unknown param)';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user