A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(operator-pass): offer flow and picker fixes (#3792)
Hampuscbe3bb26fa40
diff --git a/fluxer_api/pkgs/email/src/EmailService.ts b/fluxer_api/pkgs/email/src/EmailService.tsindex e846bc6d5..0e2753d1b 100644--- a/fluxer_api/pkgs/email/src/EmailService.ts+++ b/fluxer_api/pkgs/email/src/EmailService.ts@@ -968,7 +968,7 @@ export class EmailService implements IEmailService {);},operator_pass_offer_received: async (email, params, locale) => {- const appUrl = `${this.config.appBaseUrl}/channels/@operator-pass`;+ const appUrl = `${this.config.appBaseUrl}/channels/@operator-pass?view=passes`;return this.sendTemplatedEmail(email,'operator_pass_offer_received',diff --git a/fluxer_app/src/features/premium/components/operator_pass/OperatorPassOfferModal.tsx b/fluxer_app/src/features/premium/components/operator_pass/OperatorPassOfferModal.tsxindex 8bcf733aa..bac515b01 100644--- a/fluxer_app/src/features/premium/components/operator_pass/OperatorPassOfferModal.tsx+++ b/fluxer_app/src/features/premium/components/operator_pass/OperatorPassOfferModal.tsx@@ -211,7 +211,7 @@ const OperatorPassOfferModal = observer(function OperatorPassOfferModal({offerId? i18n._(ARRIVED_DESCRIPTOR): i18n._(ACCEPTED_DESCRIPTOR, {date: formatOperatorPassUnlockDay(result.arrives_at)}),);- ModalCommands.popByType(OperatorPassOfferModal);+ ModalCommands.popWithKey(`${OFFER_MODAL_KEY_PREFIX}${offerId}`);} catch (error) {handleError(error);} finally {@@ -225,7 +225,7 @@ const OperatorPassOfferModal = observer(function OperatorPassOfferModal({offerIdtry {await OperatorPassCommands.declineOffer(offer.id);ToastCommands.success(i18n._(DECLINED_DESCRIPTOR));- ModalCommands.popByType(OperatorPassOfferModal);+ ModalCommands.popWithKey(`${OFFER_MODAL_KEY_PREFIX}${offerId}`);} catch (error) {handleError(error);} finally {diff --git a/fluxer_app/src/features/premium/components/operator_pass/OperatorPassPassItOnModal.module.css b/fluxer_app/src/features/premium/components/operator_pass/OperatorPassPassItOnModal.module.cssdeleted file mode 100644index d607414e7..000000000--- a/fluxer_app/src/features/premium/components/operator_pass/OperatorPassPassItOnModal.module.css+++ /dev/null@@ -1,6 +0,0 @@-/* SPDX-License-Identifier: AGPL-3.0-or-later */--.root {- height: auto;- max-height: 45rem;-}diff --git a/fluxer_app/src/features/premium/components/operator_pass/OperatorPassPassItOnModal.tsx b/fluxer_app/src/features/premium/components/operator_pass/OperatorPassPassItOnModal.tsxindex 2d2da5fea..e8782bc7b 100644--- a/fluxer_app/src/features/premium/components/operator_pass/OperatorPassPassItOnModal.tsx+++ b/fluxer_app/src/features/premium/components/operator_pass/OperatorPassPassItOnModal.tsx@@ -10,7 +10,6 @@ import {import selectorStyles from '@app/features/app/components/dialogs/shared/SelectorModalStyles.module.css';import {SEARCH_FRIENDS_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';import * as OperatorPassCommands from '@app/features/premium/commands/OperatorPassCommands';-import styles from '@app/features/premium/components/operator_pass/OperatorPassPassItOnModal.module.css';import {OPERATOR_PASS_RECOGNITION_DESCRIPTOR} from '@app/features/premium/utils/OperatorPassRecognitionMessages';import {getOperatorPassErrorCode,@@ -168,7 +167,7 @@ const OperatorPassPassItOnModal = observer(function OperatorPassPassItOnModalComToastCommands.success(i18n._(OFFER_SENT_DESCRIPTOR, {name: getOperatorPassOfferUserName(offer.recipient) || name}),);- ModalCommands.popByType(OperatorPassPassItOnModal);+ ModalCommands.popWithKey(PASS_IT_ON_MODAL_KEY);} catch (error) {if (!lastPass &&@@ -190,7 +189,7 @@ const OperatorPassPassItOnModal = observer(function OperatorPassPassItOnModalCom<Modal.Rootsize="small"centered- className={styles.root}+ className={selectorStyles.selectorRoot}data-flx="premium.operator-pass-pass-it-on-modal.modal-root"><Modal.Header@@ -241,8 +240,10 @@ const OperatorPassPassItOnModal = observer(function OperatorPassPassItOnModalCom);});+const PASS_IT_ON_MODAL_KEY = 'operator-pass-pass-it-on';+export function openOperatorPassPassItOnModal(pass: OperatorPassUnitResponse, onlyPass: boolean): void {- ModalCommands.push(+ ModalCommands.pushWithKey(modal(() => (<OperatorPassPassItOnModalpass={pass}@@ -250,5 +251,6 @@ export function openOperatorPassPassItOnModal(pass: OperatorPassUnitResponse, ondata-flx="premium.operator-pass-pass-it-on-modal.open"/>)),+ PASS_IT_ON_MODAL_KEY,);}diff --git a/fluxer_app/src/features/premium/components/operator_pass/OperatorPassRoutePage.tsx b/fluxer_app/src/features/premium/components/operator_pass/OperatorPassRoutePage.tsxindex f0fae155b..79213e364 100644--- a/fluxer_app/src/features/premium/components/operator_pass/OperatorPassRoutePage.tsx+++ b/fluxer_app/src/features/premium/components/operator_pass/OperatorPassRoutePage.tsx@@ -4,11 +4,15 @@ import {Routes} from '@app/app/Routes';import {UserSettingsModal} from '@app/features/app/components/dialogs/LoadableSettingsModals';import * as RouterUtils from '@app/features/navigation/utils/RouterUtils';import {useLocation} from '@app/features/platform/components/router/RouterReact';+import {Logger} from '@app/features/platform/utils/AppLogger';+import * as OperatorPassCommands from '@app/features/premium/commands/OperatorPassCommands';import * as OperatorPassModalCommands from '@app/features/premium/commands/OperatorPassModalCommands';import {isOperatorPassAvailable} from '@app/features/premium/utils/OperatorPassUtils';import * as ModalCommands from '@app/features/ui/commands/ModalCommands';import {useEffect, useRef} from 'react';+const logger = new Logger('OperatorPassRoutePage');+export function OperatorPassRoutePage() {const location = useLocation();const handledRef = useRef(false);@@ -20,17 +24,21 @@ export function OperatorPassRoutePage() {if (!isOperatorPassAvailable()) return;const view = params.get('view');if (view === 'passes' || view === 'visionary') {- ModalCommands.push(- ModalCommands.modal(- () => (- <UserSettingsModal- initialTab="operator_pass"- data-flx="premium.operator-pass-route-page.user-settings-modal"- />+ void OperatorPassCommands.fetchPasses()+ .catch((error) => logger.warn('Failed to load Operator Passes before opening settings', error))+ .finally(() =>+ ModalCommands.push(+ ModalCommands.modal(+ () => (+ <UserSettingsModal+ initialTab="operator_pass"+ data-flx="premium.operator-pass-route-page.user-settings-modal"+ />+ ),+ 'user-settings',+ ),),- 'user-settings',- ),- );+ );return;}OperatorPassModalCommands.openCheckoutModal({diff --git a/fluxer_app/src/features/premium/components/operator_pass/OperatorPassWithdrawModal.tsx b/fluxer_app/src/features/premium/components/operator_pass/OperatorPassWithdrawModal.tsxindex 058596f65..966b45fae 100644--- a/fluxer_app/src/features/premium/components/operator_pass/OperatorPassWithdrawModal.tsx+++ b/fluxer_app/src/features/premium/components/operator_pass/OperatorPassWithdrawModal.tsx@@ -264,7 +264,7 @@ const OperatorPassWithdrawModal = observer(function OperatorPassWithdrawModal({target.onWithdrawn();}ToastCommands.success(i18n._(WITHDRAWN_TOAST_DESCRIPTOR));- ModalCommands.popByType(OperatorPassWithdrawModal);+ ModalCommands.popWithKey(WITHDRAW_MODAL_KEY);} catch (error) {logger.error('Operator Pass withdrawal failed', error);const unavailable =@@ -419,8 +419,11 @@ const OperatorPassWithdrawModal = observer(function OperatorPassWithdrawModal({);});+const WITHDRAW_MODAL_KEY = 'operator-pass-withdraw';+export function openOperatorPassWithdrawModal(target: OperatorPassWithdrawTarget): void {- ModalCommands.push(+ ModalCommands.pushWithKey(modal(() => <OperatorPassWithdrawModal target={target} data-flx="premium.operator-pass-withdraw-modal.open" />),+ WITHDRAW_MODAL_KEY,);}diff --git a/fluxer_app/src/features/user/components/modals/tabs/operator_pass_tab/OperatorPassLabsGreetingSetting.tsx b/fluxer_app/src/features/user/components/modals/tabs/operator_pass_tab/OperatorPassLabsGreetingSetting.tsxindex 404292608..e3dc92a33 100644--- a/fluxer_app/src/features/user/components/modals/tabs/operator_pass_tab/OperatorPassLabsGreetingSetting.tsx+++ b/fluxer_app/src/features/user/components/modals/tabs/operator_pass_tab/OperatorPassLabsGreetingSetting.tsx@@ -14,6 +14,7 @@ import * as ModalCommands from '@app/features/ui/commands/ModalCommands';import * as ToastCommands from '@app/features/ui/commands/ToastCommands';import {Switch} from '@app/features/ui/components/form/FormSwitch';import styles from '@app/features/user/components/modals/tabs/operator_pass_tab/OperatorPassWallSettings.module.css';+import Users from '@app/features/user/state/Users';import {msg} from '@lingui/core/macro';import {useLingui} from '@lingui/react/macro';import {observer} from 'mobx-react-lite';@@ -34,7 +35,7 @@ export const OperatorPassLabsGreetingSetting = observer(function OperatorPassLabconst {i18n} = useLingui();const [saving, setSaving] = useState(false);const labs = OperatorPassHoldings.passes?.labs;- if (!labs) return null;+ if (!labs || Users.currentUser?.operatorPassSince == null) return null;const handleChange = async (greeting: boolean) => {setSaving(true);try {