Age Verification: Separate flow from other apps (#6903)
This commit is contained in:
parent
a6a9efe602
commit
6ca0fbfacb
@ -2446,6 +2446,7 @@
|
|||||||
"TitleAgeCheckFailed" = "Age Check Failed";
|
"TitleAgeCheckFailed" = "Age Check Failed";
|
||||||
"TitleAgeCheckSuccess" = "Age Check Success";
|
"TitleAgeCheckSuccess" = "Age Check Success";
|
||||||
"ButtonAgeVerification" = "Verify My Age";
|
"ButtonAgeVerification" = "Verify My Age";
|
||||||
|
"MiniAppUnavailableError" = "Mini app is not available";
|
||||||
"GiftRibbonPremium" = "premium";
|
"GiftRibbonPremium" = "premium";
|
||||||
"NotificationGiftsLimit2_one" = "You already sent **one** of these gifts, which is the limit.";
|
"NotificationGiftsLimit2_one" = "You already sent **one** of these gifts, which is the limit.";
|
||||||
"NotificationGiftsLimit2_other" = "You already sent **{count}** of these gifts, which is the limit.";
|
"NotificationGiftsLimit2_other" = "You already sent **{count}** of these gifts, which is the limit.";
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import type { FC } from '../../../lib/teact/teact';
|
|
||||||
import { memo } from '../../../lib/teact/teact';
|
import { memo } from '../../../lib/teact/teact';
|
||||||
import { getActions, withGlobal } from '../../../global';
|
import { getActions, withGlobal } from '../../../global';
|
||||||
|
|
||||||
@ -20,27 +19,19 @@ export type OwnProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type StateProps = {
|
type StateProps = {
|
||||||
verifyAgeBotUsername?: string;
|
|
||||||
verifyAgeMin: number;
|
verifyAgeMin: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
const AgeVerificationModal: FC<OwnProps & StateProps> = ({
|
const AgeVerificationModal = ({
|
||||||
modal,
|
modal,
|
||||||
verifyAgeBotUsername,
|
|
||||||
verifyAgeMin,
|
verifyAgeMin,
|
||||||
}) => {
|
}: OwnProps & StateProps) => {
|
||||||
const { closeAgeVerificationModal, openChatByUsername } = getActions();
|
const { closeAgeVerificationModal, requestAgeVerification } = getActions();
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
const isOpen = Boolean(modal);
|
const isOpen = Boolean(modal);
|
||||||
|
|
||||||
const handleVerifyAge = useLastCallback(() => {
|
const handleVerifyAge = useLastCallback(() => {
|
||||||
if (verifyAgeBotUsername) {
|
requestAgeVerification();
|
||||||
openChatByUsername({
|
|
||||||
shouldStartMainApp: true,
|
|
||||||
username: verifyAgeBotUsername,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
closeAgeVerificationModal();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleClose = useLastCallback(() => {
|
const handleClose = useLastCallback(() => {
|
||||||
@ -86,11 +77,9 @@ const AgeVerificationModal: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
export default memo(withGlobal((global): Complete<StateProps> => {
|
export default memo(withGlobal((global): Complete<StateProps> => {
|
||||||
const appConfig = global.appConfig;
|
const appConfig = global.appConfig;
|
||||||
const verifyAgeBotUsername = appConfig.verifyAgeBotUsername;
|
|
||||||
const verifyAgeMin = appConfig.verifyAgeMin || VERIFY_AGE_MIN_DEFAULT;
|
const verifyAgeMin = appConfig.verifyAgeMin || VERIFY_AGE_MIN_DEFAULT;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
verifyAgeBotUsername,
|
|
||||||
verifyAgeMin,
|
verifyAgeMin,
|
||||||
};
|
};
|
||||||
})(AgeVerificationModal));
|
})(AgeVerificationModal));
|
||||||
|
|||||||
@ -703,6 +703,42 @@ addActionHandler('requestWebView', async (global, actions, payload): Promise<voi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addActionHandler('requestAgeVerification', async (global, actions, payload): Promise<void> => {
|
||||||
|
const { tabId = getCurrentTabId() } = payload || {};
|
||||||
|
const { verifyAgeBotUsername } = global.appConfig;
|
||||||
|
|
||||||
|
if (!verifyAgeBotUsername) {
|
||||||
|
actions.showNotification({
|
||||||
|
message: { key: 'MiniAppUnavailableError' },
|
||||||
|
tabId,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const chat = await fetchChatByUsername(global, verifyAgeBotUsername);
|
||||||
|
global = getGlobal();
|
||||||
|
const bot = chat && selectUser(global, chat.id);
|
||||||
|
|
||||||
|
if (!bot?.hasMainMiniApp) {
|
||||||
|
actions.showNotification({
|
||||||
|
message: { key: 'MiniAppUnavailableError' },
|
||||||
|
tabId,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const theme = extractCurrentThemeParams();
|
||||||
|
actions.requestMainWebView({
|
||||||
|
botId: bot.id,
|
||||||
|
peerId: bot.id,
|
||||||
|
theme,
|
||||||
|
shouldMarkBotTrusted: true,
|
||||||
|
tabId,
|
||||||
|
});
|
||||||
|
|
||||||
|
actions.closeAgeVerificationModal({ tabId });
|
||||||
|
});
|
||||||
|
|
||||||
addActionHandler('requestMainWebView', async (global, actions, payload): Promise<void> => {
|
addActionHandler('requestMainWebView', async (global, actions, payload): Promise<void> => {
|
||||||
const {
|
const {
|
||||||
botId, peerId, theme, startParam, mode, shouldMarkBotTrusted,
|
botId, peerId, theme, startParam, mode, shouldMarkBotTrusted,
|
||||||
@ -717,7 +753,14 @@ addActionHandler('requestMainWebView', async (global, actions, payload): Promise
|
|||||||
if (checkIfOpenOrActivate(global, botId, tabId)) return;
|
if (checkIfOpenOrActivate(global, botId, tabId)) return;
|
||||||
|
|
||||||
const bot = selectUser(global, botId);
|
const bot = selectUser(global, botId);
|
||||||
if (!bot) return;
|
if (!bot) {
|
||||||
|
actions.showNotification({
|
||||||
|
message: { key: 'MiniAppUnavailableError' },
|
||||||
|
tabId,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const peer = selectPeer(global, peerId);
|
const peer = selectPeer(global, peerId);
|
||||||
if (!peer) return;
|
if (!peer) return;
|
||||||
|
|
||||||
@ -748,6 +791,10 @@ addActionHandler('requestMainWebView', async (global, actions, payload): Promise
|
|||||||
mode,
|
mode,
|
||||||
});
|
});
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
actions.showNotification({
|
||||||
|
message: { key: 'MiniAppUnavailableError' },
|
||||||
|
tabId,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1149,6 +1149,7 @@ export interface ActionPayloads {
|
|||||||
closeDeleteAccountModal: WithTabId | undefined;
|
closeDeleteAccountModal: WithTabId | undefined;
|
||||||
openAgeVerificationModal: WithTabId | undefined;
|
openAgeVerificationModal: WithTabId | undefined;
|
||||||
closeAgeVerificationModal: WithTabId | undefined;
|
closeAgeVerificationModal: WithTabId | undefined;
|
||||||
|
requestAgeVerification: WithTabId | undefined;
|
||||||
setAccountTTL: {
|
setAccountTTL: {
|
||||||
days: number;
|
days: number;
|
||||||
} & WithTabId | undefined;
|
} & WithTabId | undefined;
|
||||||
|
|||||||
1
src/types/language.d.ts
vendored
1
src/types/language.d.ts
vendored
@ -1797,6 +1797,7 @@ export interface LangPair {
|
|||||||
'TitleAgeCheckFailed': undefined;
|
'TitleAgeCheckFailed': undefined;
|
||||||
'TitleAgeCheckSuccess': undefined;
|
'TitleAgeCheckSuccess': undefined;
|
||||||
'ButtonAgeVerification': undefined;
|
'ButtonAgeVerification': undefined;
|
||||||
|
'MiniAppUnavailableError': undefined;
|
||||||
'GiftRibbonPremium': undefined;
|
'GiftRibbonPremium': undefined;
|
||||||
'PremiumGiftHeader': undefined;
|
'PremiumGiftHeader': undefined;
|
||||||
'PriceInStars': undefined;
|
'PriceInStars': undefined;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user