From dedc56cf1054fd04020fcc660be365f185d23463 Mon Sep 17 00:00:00 2001 From: Or Antonio Orsatti <109456266+ororsatti@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:01:57 +0200 Subject: [PATCH 1/5] End up in a really bad state when I swipe right on mobile [0XP-1663] (#2128) replaced `uniqWith` with a `filter` calls --------- Co-authored-by: Richard Liu --- .../Modals/PodsCollectionBottomModal.tsx | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/apps/passport-client/new-components/shared/Modals/PodsCollectionBottomModal.tsx b/apps/passport-client/new-components/shared/Modals/PodsCollectionBottomModal.tsx index 3b936a0cbf..c70e7eac03 100644 --- a/apps/passport-client/new-components/shared/Modals/PodsCollectionBottomModal.tsx +++ b/apps/passport-client/new-components/shared/Modals/PodsCollectionBottomModal.tsx @@ -1,9 +1,5 @@ import { isEdDSAFrogPCD } from "@pcd/eddsa-frog-pcd"; - -import { - EdDSATicketPCDTypeName, - isEdDSATicketPCD -} from "@pcd/eddsa-ticket-pcd"; +import { isEdDSATicketPCD } from "@pcd/eddsa-ticket-pcd"; import { isEmailPCD } from "@pcd/email-pcd"; import { PCD } from "@pcd/pcd-types"; import { @@ -45,24 +41,25 @@ import { replaceDotWithSlash, useOrientation } from "../utils"; -import { uniqWith } from "lodash"; const filterOverlappingEdDSATickets = ( pcds: PCD[] ): PCD[] => { - const noDupTickets = uniqWith(pcds.reverse(), (a, b) => { - const isPodOrEddsa1 = isPODTicketPCD(a) || isEdDSATicketPCD(a); - const isPodOrEddsa2 = isPODTicketPCD(b) || isEdDSATicketPCD(b); - if (!isPodOrEddsa1 || !isPodOrEddsa2) return false; - return ( - a.claim.ticket.attendeeEmail === b.claim.ticket.attendeeEmail && - a.claim.ticket.eventId === b.claim.ticket.eventId && - a.type === EdDSATicketPCDTypeName - ); - }); + const eddsaTickets = pcds.filter(isEdDSATicketPCD); + const podTickets = pcds.filter(isPODTicketPCD); + const overlapping = eddsaTickets + .filter((eddsa) => + podTickets.find( + (pod) => + pod.claim.ticket.attendeeEmail === eddsa.claim.ticket.attendeeEmail && + pod.claim.ticket.eventId === eddsa.claim.ticket.eventId + ) + ) + .map((eddsa) => eddsa.id); + + const noEmails = pcds.filter((p) => !isEmailPCD(p)); - const noEmails = noDupTickets.filter((p) => !isEmailPCD(p)); - return noEmails; + return noEmails.filter((pcd) => !overlapping.includes(pcd.id)); }; const getPcdName = (pcd: PCD): string => { switch (true) { @@ -155,7 +152,6 @@ export const PodsCollectionList = ({ LeftIcon: getPCDImage(pcd) }); } - return Object.values(result) .map((group) => { if (!searchQuery) { @@ -219,6 +215,7 @@ export const PodsCollectionBottomModal = (): JSX.Element | null => { const dispatch = useDispatch(); const [params, setParams] = useSearchParams(); const orientation = useOrientation(); + const isLandscape = orientation.type === "landscape-primary" || orientation.type === "landscape-secondary"; @@ -285,6 +282,7 @@ export const PodsCollectionBottomModal = (): JSX.Element | null => { isPodsCollectionModalOpen, setExpandedGroupsIds ]); + const handlePodClick = useCallback( (pcd: PCD) => { listContainerRef.current && From 5f6fc0e81ac123fcdc7095872bf7484d20a61d9a Mon Sep 17 00:00:00 2001 From: Or Antonio Orsatti <109456266+ororsatti@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:03:08 +0200 Subject: [PATCH 2/5] 0XP-1659 Sync message does not update when we resync (#2129) - add check for extra sync triggers - added more sync states. --------- Co-authored-by: Richard Liu --- .../screens/Home/SyncIndicator.tsx | 50 +++++++++++++------ apps/passport-client/src/appHooks.ts | 8 ++- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/apps/passport-client/new-components/screens/Home/SyncIndicator.tsx b/apps/passport-client/new-components/screens/Home/SyncIndicator.tsx index 0fe58d6bf8..273012c69a 100644 --- a/apps/passport-client/new-components/screens/Home/SyncIndicator.tsx +++ b/apps/passport-client/new-components/screens/Home/SyncIndicator.tsx @@ -3,33 +3,53 @@ import { useIsSyncSettled } from "../../../src/appHooks"; import { NewLoader } from "../../shared/NewLoader"; import { Typography } from "../../shared/Typography"; +const syncStates = { + now: (_: number): string => "Synced just now", + near: (_: number): string => "Synced a few seconds ago", + aboutMinute: (_: number): string => "Synced about a minute ago", + minutes: (seconds: number): string => `Synced ${seconds / 60} minutes ago` +} as const; + +const getSyncState = (seconds: number): keyof typeof syncStates => { + switch (true) { + case seconds <= 10: + return "now"; + case seconds <= 50: + return "near"; + case seconds <= 120: + return "aboutMinute"; + default: + return "minutes"; + } +}; export const SyncIndicator = (): ReactElement => { - const [minutesSinceSynced, setMinutesSinceSynced] = useState(0); + const [syncState, setSyncState] = useState(); const isSyncSettled = useIsSyncSettled(); useEffect(() => { + let seconds = 0; const interval = setInterval(() => { if (isSyncSettled) { - setMinutesSinceSynced((oldValue) => oldValue + 1); + seconds += 10; + setSyncState(syncStates[getSyncState(seconds)](seconds)); } else { - setMinutesSinceSynced(0); + setSyncState(undefined); + seconds = 0; } - }, 60000); + }, 10000); + if (isSyncSettled) { + seconds += 10; + setSyncState(syncStates[getSyncState(seconds)](seconds)); + } else { + setSyncState(undefined); + seconds = 0; + } return () => clearInterval(interval); }, [isSyncSettled]); - if (isSyncSettled) { - if (minutesSinceSynced) { - return ( - - Synced {minutesSinceSynced} minute - {minutesSinceSynced > 1 ? "s" : ""} ago - - ); - } else { - return Just synced; - } + if (isSyncSettled && syncState) { + return {syncState}; } return ( ((s) => !!s.loadedIssuedPCDs, []); } +export function useExtraSubscriptionFetchRequested(): boolean { + return useSelector((s) => !!s.extraSubscriptionFetchRequested, []); +} + export function useIsDownloaded(): boolean { return useSelector((s) => !!s.downloadedPCDs, []); } @@ -231,8 +235,8 @@ export function useUserShouldAgreeNewPrivacyNotice(): void { export function useIsSyncSettled(): boolean { const isDownloaded = useIsDownloaded(); const loadedIssued = useLoadedIssuedPCDs(); - - return isDownloaded && loadedIssued; + const extraFetchSubscriptionRequested = useExtraSubscriptionFetchRequested(); + return isDownloaded && loadedIssued && !extraFetchSubscriptionRequested; } export function useIsLoggedIn(): boolean { From 7cc7dc5d3c792af9b1f2a32260b624555428b14a Mon Sep 17 00:00:00 2001 From: Richard Liu Date: Thu, 7 Nov 2024 09:17:43 -0800 Subject: [PATCH 3/5] 0XP-1652: Add-ons fix (#2132) - got addon_to info within podbox - update EdDSATicket as well and update isAddOn logic --------- Co-authored-by: or orsatti --- .../resources/one-click-page/index.html | 83 ++++++++++++------- .../routing/routes/genericIssuanceRoutes.ts | 48 ++++++----- .../pipelines/PretixPipeline.ts | 26 ++++-- .../test/pretix/GenericPretixDataMocker.ts | 3 +- .../src/genericPretixTypes.ts | 1 + .../eddsa-ticket-pcd/src/EdDSATicketPCD.ts | 1 + packages/pcd/pod-ticket-pcd/src/schema.ts | 3 +- 7 files changed, 105 insertions(+), 60 deletions(-) diff --git a/apps/passport-server/resources/one-click-page/index.html b/apps/passport-server/resources/one-click-page/index.html index 857f83ee0f..2561a81800 100644 --- a/apps/passport-server/resources/one-click-page/index.html +++ b/apps/passport-server/resources/one-click-page/index.html @@ -324,6 +324,7 @@ font-style: normal; font-weight: 500; line-height: 135%; + user-select: none; /* 18.9px */ } @@ -509,7 +510,7 @@ {{#showAddons}} - - @@ -622,11 +624,11 @@