Files
discord-decomp/modules/webauthn/native/PasskeyUpsellManager.tsx
T
2026-11-01 12:12:55 +02:00

59 lines
2.4 KiB
TypeScript

// Metro module 13757 (f13758).
import AuthenticationStore from "../../../stores/AuthenticationStore";
import UserStore from "../../../stores/UserStore";
import WebAuthnStore from "../WebAuthnStore";
import { LoginStates } from "../../../Constants";
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
import { hasWebAuthn } from "../../../utils/MFAUtils";
import { UNSAFE_isDismissibleContentDismissed, UNSAFE_markDismissibleContentAsDismissed } from "../../dismissible_content/DismissibleContentUnsafeUtils";
import { DismissibleContent } from "../../../_bundle/Module1358";
import { isModalOpen } from "../../main_tabs_v2/helpers/NavigationRouteUtils.native";
import { fetchWebAuthnCredentials } from "../WebAuthnActionCreators";
import PasskeyUpsellActionCreators from "./PasskeyUpsellActionCreators";
let c9569_7 = false;
let c9569_8 = false;
class PasskeyUpsellManager extends AutomaticLifecycleManager {
actions = {
POST_CONNECTION_OPEN: this.handlePasskeyUpsellShow,
LOGIN_RESET: this.handleLogout,
LOGIN_SUCCESS: this.handleLoginSuccess,
LOGOUT: this.handleLogout
};
stores = new Map().set(AuthenticationStore, this.handlePasskeyUpsellShow).set(UserStore, this.handlePasskeyUpsellShow).set(WebAuthnStore, this.handlePasskeyUpsellShow);
handlePasskeyUpsellShow() {
L15: {
if (c9569_8 && hasWebAuthn && AuthenticationStore.getLoginStatus() === LoginStates.NONE && AuthenticationStore.attemptedPasswordLogin() && !UNSAFE_isDismissibleContentDismissed(DismissibleContent.PASSWORDLESS_UPSELL)) {
if (WebAuthnStore.hasFetchedCredentials() && WebAuthnStore.hasCredentials) {
break L15;
}
if (!isModalOpen()) {
const currentUser = UserStore.getCurrentUser();
if (currentUser !== void 0 && currentUser.verified) {
if (WebAuthnStore.hasFetchedCredentials()) {
PasskeyUpsellActionCreators.openPasskeyUpsell();
} else if (!c9569_7) {
c9569_7 = true;
fetchWebAuthnCredentials();
}
}
}
}
}
}
handleLoginSuccess() {
c9569_8 = true;
}
handleLogout() {
c9569_7 = false;
c9569_8 = false;
}
markDismissed(a0) {
return UNSAFE_markDismissibleContentAsDismissed(DismissibleContent.PASSWORDLESS_UPSELL, {
dismissAction: a0,
forceTrack: true
});
}
}
const passkeyUpsellManager = new PasskeyUpsellManager();
export default passkeyUpsellManager;