Skip to content

Commit 54e3da9

Browse files
fix: use favicon for app icon
1 parent 0d06c71 commit 54e3da9

File tree

7 files changed

+38
-67
lines changed

7 files changed

+38
-67
lines changed

apps/mobile/src/features/account/account-selector/account-selector-sheet.layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function AccountSelectorSheetLayout({
7575
<AccountCard
7676
caption={wallet.name}
7777
primaryTitle={account.name}
78-
appIcons={connectedAppsToAccountIdMap[account.id]?.map(app => app.icon)}
78+
appOrigins={connectedAppsToAccountIdMap[account.id]?.map(app => app.origin)}
7979
secondaryTitle={
8080
<AccountBalance
8181
variant="label01"

apps/mobile/src/features/account/components/account-card.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface AccountCardProps extends PressableProps {
1919
onLongPress?(): void;
2020
testID?: string;
2121
iconTestID?: string;
22-
appIcons?: string[];
22+
appOrigins?: string[];
2323
isLoading?: boolean;
2424
width?: number;
2525
}
@@ -31,7 +31,7 @@ export function AccountCard({
3131
icon,
3232
address,
3333
onPress,
34-
appIcons,
34+
appOrigins,
3535
isLoading,
3636
width,
3737
testID,
@@ -71,7 +71,7 @@ export function AccountCard({
7171
</Box>
7272
<Title>{secondaryTitle}</Title>
7373
</Box>
74-
{appIcons && <AppIcons appIcons={appIcons} />}
74+
{appOrigins && <AppIcons appOrigins={appOrigins} />}
7575
</Card>
7676
);
7777
}

apps/mobile/src/features/accounts/components/app-icons.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import { useTheme } from '@shopify/restyle';
2-
import { Image } from 'expo-image';
32

4-
import { Box, Theme } from '@leather.io/ui/native';
3+
import { Box, Favicon, Theme } from '@leather.io/ui/native';
54

65
interface AppIconsProps {
7-
appIcons: string[];
6+
appOrigins: string[];
87
}
9-
export function AppIcons({ appIcons }: AppIconsProps) {
10-
const { spacing, colors } = useTheme<Theme>();
8+
export function AppIcons({ appOrigins }: AppIconsProps) {
9+
const { spacing } = useTheme<Theme>();
1110
return (
1211
<Box position="absolute" right={spacing['4']} top={spacing['7']} flexDirection="row">
13-
{appIcons.slice(0, 8).map((icon, idx) => (
14-
<Image
15-
key={icon}
12+
{appOrigins.slice(0, 8).map((origin, idx) => (
13+
<Box
14+
key={origin}
15+
position="absolute"
16+
width={18}
17+
height={18}
18+
right={idx * spacing[4]}
19+
borderRadius="round"
20+
borderColor="ink.background-primary"
21+
borderWidth={1}
1622
style={{
17-
position: 'absolute',
18-
width: 18,
19-
height: 18,
20-
right: idx * spacing[4],
2123
zIndex: (100 - idx) * 1,
22-
borderRadius: 999,
23-
borderColor: colors['ink.background-primary'],
24-
borderWidth: 1,
2524
}}
26-
source={{ uri: icon }}
27-
/>
25+
>
26+
<Favicon origin={origin} size={16} />
27+
</Box>
2828
))}
2929
</Box>
3030
);

apps/mobile/src/features/browser/browser/browser-active-state.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
BrowserLoading,
88
BrowserLoadingMethods,
99
} from '@/features/accounts/components/browser-loading';
10-
import { getFaviconAndSave } from '@/filesystem/favicon';
1110
import { userAddsApp } from '@/store/apps/apps.write';
1211
import { useAppDispatch } from '@/store/utils';
1312
import { useTheme } from '@shopify/restyle';
@@ -67,19 +66,15 @@ export function BrowserActiveState({
6766
goToUrl(newNavState.url);
6867
if (newNavState.loading) return;
6968

70-
const uri = await getFaviconAndSave(url.hostname);
7169
const screenshotUri = await captureScreenshot(viewShotRef, url.hostname);
72-
if (uri) {
73-
dispatch(
74-
userAddsApp({
75-
icon: uri,
76-
screenshot: screenshotUri ?? null,
77-
name: newNavState.title,
78-
origin: url.origin,
79-
status: 'recently_visited',
80-
})
81-
);
82-
}
70+
dispatch(
71+
userAddsApp({
72+
screenshot: screenshotUri ?? null,
73+
name: newNavState.title,
74+
origin: url.origin,
75+
status: 'recently_visited',
76+
})
77+
);
8378
}
8479
function postMessage(result: string) {
8580
webViewRef.current?.injectJavaScript(`window.onMessageFromRN(${result});`);

apps/mobile/src/features/browser/browser/screenshot-card.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ import { App } from '@/store/apps/utils';
55
import { useAppDispatch } from '@/store/utils';
66
import { Image } from 'expo-image';
77

8-
import { Box, CloseIcon, Pressable, Text, legacyTouchablePressEffect } from '@leather.io/ui/native';
8+
import {
9+
Box,
10+
CloseIcon,
11+
Favicon,
12+
Pressable,
13+
Text,
14+
legacyTouchablePressEffect,
15+
} from '@leather.io/ui/native';
916

1017
const { width } = Dimensions.get('window');
1118

@@ -30,7 +37,7 @@ export function ScreenshotCard({ app, onPress }: ScreenshotCardProps) {
3037
flexShrink={1}
3138
overflow="hidden"
3239
>
33-
<Image style={{ width: 24, height: 24, borderRadius: 999 }} source={{ uri: app.icon }} />
40+
<Favicon origin={app.origin} size={16} />
3441
<Text style={{ flexShrink: 1 }} numberOfLines={1}>
3542
{app.name}
3643
</Text>

apps/mobile/src/filesystem/favicon.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

apps/mobile/src/store/apps/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import z from 'zod';
22

33
const baseAppSchema = z.object({
44
origin: z.string(),
5-
icon: z.string(),
65
screenshot: z.union([z.string(), z.null()]),
76
name: z.string(),
87
});

0 commit comments

Comments
 (0)