Skip to content

Commit

Permalink
Merge branch 'main' into rohan/admiring-tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohan-cp authored Oct 25, 2023
2 parents e62d1bd + 5255e6f commit 49bdf9d
Show file tree
Hide file tree
Showing 400 changed files with 7,104 additions and 2,377 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ Hit up a member of the core team!
- `moon run web:typecheck` for checking type validity
- `moon run web:synpress-run` to run e2e tests
- `moon run web:synpress-open` to open cypress
- `yarn fetch-schema` to pull graphql schema from production
- `yarn fetch-schema-dev` to pull graphql schema from development
2 changes: 1 addition & 1 deletion apps/mobile/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
orientation: 'portrait',
icon: './assets/icon.png',
userInterfaceStyle: 'automatic',
version: '1.0.26',
version: '1.0.28',
updates: {
fallbackToCacheTimeout: 0,
},
Expand Down
80 changes: 80 additions & 0 deletions apps/mobile/src/components/AnimatedRefreshIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { useCallback, useEffect, useRef } from 'react';
import { Animated } from 'react-native';
import { RefreshIcon } from 'src/icons/RefreshIcon';

import { IconContainer } from '~/components/IconContainer';
import { useToastActions } from '~/contexts/ToastContext';
import { contexts } from '~/shared/analytics/constants';

type AnimatedRefreshIconProps = {
onSync: () => void;
onRefresh: () => void;
isSyncing: boolean;
eventElementId: string;
eventName: string;
};

export function AnimatedRefreshIcon({
onSync,
onRefresh,
isSyncing,
eventElementId,
eventName,
}: AnimatedRefreshIconProps) {
const { pushToast } = useToastActions();

const handleSync = useCallback(async () => {
if (isSyncing) return;

await onSync();
onRefresh();
pushToast({
message: 'Successfully refreshed your collection',
withoutNavbar: true,
});
}, [isSyncing, onSync, onRefresh, pushToast]);

const spinValue = useRef(new Animated.Value(0)).current;

const spin = useCallback(() => {
spinValue.setValue(0);
Animated.timing(spinValue, {
toValue: 1,
duration: 1000,
useNativeDriver: true,
}).start(({ finished }) => {
// Only repeat the animation if it completed (wasn't interrupted) and isSyncing is still true
if (finished && isSyncing) {
spin();
}
});
}, [isSyncing, spinValue]);

const spinAnimation = spinValue.interpolate({
inputRange: [0, 1],
outputRange: ['0deg', '360deg'],
});

useEffect(() => {
if (isSyncing) {
spin();
} else {
spinValue.stopAnimation();
}
}, [isSyncing, spin, spinValue]);

return (
<IconContainer
size="sm"
onPress={handleSync}
icon={
<Animated.View style={{ transform: [{ rotate: spinAnimation }] }}>
<RefreshIcon />
</Animated.View>
}
eventElementId={eventElementId}
eventName={eventName}
eventContext={contexts.Posts}
/>
);
}
1 change: 1 addition & 0 deletions apps/mobile/src/components/BackButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function BackButton({ onPress, size = 'md' }: Props) {
size={size}
eventElementId={null}
eventName={null}
eventContext={null}
icon={<BackIcon />}
onPress={handlePress}
/>
Expand Down
54 changes: 54 additions & 0 deletions apps/mobile/src/components/BottomSheetRow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import clsx from 'clsx';
import { View } from 'react-native';

import { GalleryElementTrackingProps } from '~/shared/contexts/AnalyticsContext';

import { GalleryTouchableOpacity } from './GalleryTouchableOpacity';
import { Typography } from './Typography';

type BottomSheetRowProps = {
icon?: React.ReactNode;
text: string;
onPress: () => void;
style?: React.ComponentProps<typeof GalleryTouchableOpacity>['style'];
isConfirmationRow?: boolean;
fontWeight?: 'Regular' | 'Bold';
rightIcon?: React.ReactNode;
eventContext: GalleryElementTrackingProps['eventContext'];
};

export function BottomSheetRow({
icon,
text,
onPress,
style,
isConfirmationRow,
fontWeight = 'Regular',
rightIcon,
eventContext,
}: BottomSheetRowProps) {
return (
<GalleryTouchableOpacity
onPress={onPress}
eventElementId="Bottom Sheet Row"
eventName="Bottom Sheet Row Press"
eventContext={eventContext}
properties={{ selection: text }}
style={style}
>
<View className="bg-offWhite dark:bg-black-800 p-3 flex-row items-center">
{icon && <View className="mr-2">{icon}</View>}
<Typography
font={{ family: 'ABCDiatype', weight: fontWeight }}
className={clsx(
'text-sm',
isConfirmationRow ? 'text-red' : 'text-black-900 dark:text-offWhite'
)}
>
{text}
</Typography>
{rightIcon && <View className="ml-auto">{rightIcon}</View>}
</View>
</GalleryTouchableOpacity>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { GalleryTouchableOpacity } from '~/components/GalleryTouchableOpacity';
import { useTokenStateManagerContext } from '~/contexts/TokenStateManagerContext';
import { TokenFailureFallbacksErrorFallbackFragment$key } from '~/generated/TokenFailureFallbacksErrorFallbackFragment.graphql';
import { TokenFailureFallbacksLoadingFallbackFragment$key } from '~/generated/TokenFailureFallbacksLoadingFallbackFragment.graphql';
import { contexts } from '~/shared/analytics/constants';

export type FallbackProps = {
fallbackAspectSquare?: boolean;
Expand Down Expand Up @@ -80,6 +81,7 @@ export function TokenPreviewErrorFallback({
onPress={handlePress}
eventElementId="Refresh Broken Token Button"
eventName="Refresh Broken Token Pressed"
eventContext={contexts.Error}
activeOpacity={refreshable ? 0.2 : 1}
>
<Text
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/components/ButtonChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ export function ButtonChip({
<GalleryTouchableOpacity
onPressIn={() => setActive(true)}
onPressOut={() => setActive(false)}
// TODO: analytics this should be prop drilled
eventElementId="Follow Button"
eventName="Follow Button Clicked"
eventContext={null}
activeOpacity={1}
properties={{ variant, ...eventProperties }}
onPress={onPress}
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/components/CommunitiesList/CommunityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { graphql } from 'relay-runtime';

import { Typography } from '~/components/Typography';
import { CommunityCardFragment$key } from '~/generated/CommunityCardFragment.graphql';
import { contexts } from '~/shared/analytics/constants';

import { GalleryTouchableOpacity } from '../GalleryTouchableOpacity';
import { Markdown } from '../Markdown';
Expand Down Expand Up @@ -48,6 +49,7 @@ export function CommunityCard({ communityRef, onPress }: CommunityCardProps) {
className="flex flex-row items-center space-x-4 py-2 px-4"
eventElementId="Community Name"
eventName="Community Name Clicked"
eventContext={contexts.Community}
>
<CommunityProfilePicture communityRef={community} size="md" />

Expand Down
6 changes: 4 additions & 2 deletions apps/mobile/src/components/Community/CommunityHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { View } from 'react-native';
import { graphql, useFragment } from 'react-relay';

import { CommunityHeaderFragment$key } from '~/generated/CommunityHeaderFragment.graphql';
import { contexts } from '~/shared/analytics/constants';
import { truncateAddress } from '~/shared/utils/wallet';

import { GalleryBottomSheetModalType } from '../GalleryBottomSheet/GalleryBottomSheetModal';
Expand Down Expand Up @@ -53,8 +54,9 @@ export function CommunityHeader({ communityRef }: Props) {
<GalleryTouchableOpacity
className="flex-1"
onPress={handlePress}
eventElementId={null}
eventName={null}
eventElementId="Community Header"
eventName="Community Header Press"
eventContext={contexts.Community}
disabled={!hasCommunityDescription}
>
<View>
Expand Down
19 changes: 15 additions & 4 deletions apps/mobile/src/components/Community/CommunityMeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { CommunityMetaQueryFragment$key } from '~/generated/CommunityMetaQueryFr
import { CommunityMetaRefetchQuery } from '~/generated/CommunityMetaRefetchQuery.graphql';
import { PostIcon } from '~/navigation/MainTabNavigator/PostIcon';
import { MainTabStackNavigatorProp } from '~/navigation/types';
import { contexts } from '~/shared/analytics/constants';
import colors from '~/shared/theme/colors';

import { Button } from '../Button';
Expand Down Expand Up @@ -160,6 +161,7 @@ export function CommunityMeta({ communityRef, queryRef }: Props) {
onPress={handleUsernamePress}
eventElementId="Community Page Creator Username"
eventName="Tapped Community Page Creator Username"
eventContext={contexts.Community}
>
{community.creator.__typename && <ProfilePicture userRef={community.creator} size="xs" />}

Expand All @@ -174,12 +176,20 @@ export function CommunityMeta({ communityRef, queryRef }: Props) {
} else if (community.contractAddress) {
return (
<View className="flex flex-row items-center space-x-1">
<RawProfilePicture size="xs" default eventElementId={null} eventName={null} />
<RawProfilePicture
size="xs"
default
eventElementId="Community PFP"
eventName="Community PFP Press"
eventContext={contexts.Community}
/>
<LinkableAddress
chainAddressRef={community.contractAddress}
type="Community Contract Address"
textStyle={{ color: colorScheme === 'light' ? colors.black[800] : colors.offWhite }}
font={{ family: 'ABCDiatype', weight: 'Bold' }}
eventElementId="Community Contract Address"
eventName="Community Contract Address Press"
eventContext={contexts.Community}
/>
</View>
);
Expand Down Expand Up @@ -228,8 +238,9 @@ export function CommunityMeta({ communityRef, queryRef }: Props) {
variant={isMemberOfCommunity ? 'primary' : 'disabled'}
icon={<PostIcon width={16} color={PostIconColor} strokeWidth={2} />}
onPress={handlePress}
eventElementId={null}
eventName={null}
eventElementId="Attempt Create Post Button"
eventName="Attempt Create Post"
eventContext={contexts.Community}
/>
<CommunityPostBottomSheet
ref={bottomSheetRef}
Expand Down
18 changes: 13 additions & 5 deletions apps/mobile/src/components/Community/CommunityPostBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { Text, View } from 'react-native';
import { graphql, useFragment } from 'react-relay';
import { RefreshIcon } from 'src/icons/RefreshIcon';

import { useSyncTokenstActions } from '~/contexts/SyncTokensContext';
import { useSyncTokensActions } from '~/contexts/SyncTokensContext';
import { useToastActions } from '~/contexts/ToastContext';
import { CommunityPostBottomSheetFragment$key } from '~/generated/CommunityPostBottomSheetFragment.graphql';
import { contexts } from '~/shared/analytics/constants';

import { Button } from '../Button';
import {
Expand Down Expand Up @@ -38,7 +39,7 @@ function CommunityPostBottomSheet(
);

const { bottom } = useSafeAreaPadding();
const { isSyncing, syncTokens } = useSyncTokenstActions();
const { isSyncing, syncTokens } = useSyncTokensActions();
const { pushToast } = useToastActions();

const bottomSheetRef = useRef<GalleryBottomSheetModalType | null>(null);
Expand Down Expand Up @@ -105,15 +106,22 @@ function CommunityPostBottomSheet(
refreshing your collection.
</Typography>
</Text>
<Button text="Ok" onPress={closeBottomSheet} eventElementId={null} eventName={null} />
<Button
text="Ok"
onPress={closeBottomSheet}
eventElementId={null}
eventName={null}
eventContext={null}
/>
<Button
text="Refresh collection"
variant="secondary"
loading={isSyncing}
onPress={handleSync}
icon={<RefreshIcon />}
eventElementId={null}
eventName={null}
eventElementId="Refresh Tokens From Community Screen Button"
eventName="Refresh Tokens From Community Screen"
eventContext={contexts.Posts}
/>
</View>
</View>
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/components/Community/CommunityTabsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { View } from 'react-native';
import { graphql, useFragment } from 'react-relay';

import { CommunityTabsHeaderFragment$key } from '~/generated/CommunityTabsHeaderFragment.graphql';
import { contexts } from '~/shared/analytics/constants';

import { GalleryTabBar } from '../GalleryTabs/GalleryTabBar';

Expand Down Expand Up @@ -59,6 +60,7 @@ export function CommunityTabsHeader({ selectedRoute, onRouteChange, communityRef
routes={routes}
eventElementId="Community Tab"
eventName="Community Tab Clicked"
eventContext={contexts.Community}
/>
</View>
);
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/components/Community/CommunityView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { graphql, useFragment } from 'react-relay';
import { ShareIcon } from 'src/icons/ShareIcon';

import { CommunityViewFragment$key } from '~/generated/CommunityViewFragment.graphql';
import { contexts } from '~/shared/analytics/constants';

import { BackButton } from '../BackButton';
import { GalleryTabsContainer } from '../GalleryTabs/GalleryTabsContainer';
Expand Down Expand Up @@ -93,6 +94,7 @@ export function CommunityView({ queryRef }: Props) {
<IconContainer
eventElementId="Community Share Icon"
eventName="Community Share Icon Clicked"
eventContext={contexts.Community}
icon={<ShareIcon />}
onPress={handleShare}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { Typography } from '~/components/Typography';
import { CommunityViewPostsTabFragment$key } from '~/generated/CommunityViewPostsTabFragment.graphql';
import { CommunityViewPostsTabQueryFragment$key } from '~/generated/CommunityViewPostsTabQueryFragment.graphql';
import { MainTabStackNavigatorProp } from '~/navigation/types';
import { contexts } from '~/shared/analytics/constants';
import { noop } from '~/shared/utils/noop';

import { CommunityPostBottomSheet } from '../CommunityPostBottomSheet';

Expand Down Expand Up @@ -115,7 +117,7 @@ export function CommunityViewPostsTab({ communityRef, queryRef }: Props) {
itemId = item.eventId;
}

const markFailure = () => (itemId ? markEventAsFailure(itemId) : () => {});
const markFailure = () => (itemId ? markEventAsFailure(itemId) : noop);

return <FeedVirtualizedRow item={item} onFailure={markFailure} />;
},
Expand Down Expand Up @@ -165,14 +167,15 @@ export function CommunityViewPostsTab({ communityRef, queryRef }: Props) {
<Button
text={'CREATE A POST'}
onPress={handleCreatePost}
eventElementId={null}
eventName={null}
eventElementId="Empty View Create Post Button"
eventName="Empty View Create Post Button Press"
eventContext={contexts.Posts}
/>

<CommunityPostBottomSheet
ref={bottomSheetRef}
communityRef={community}
onRefresh={() => {}}
onRefresh={noop}
/>
</View>
</View>
Expand Down
Loading

0 comments on commit 49bdf9d

Please sign in to comment.