Skip to content

Commit a9619ed

Browse files
Merge upstream develop
2 parents ed254a3 + 5b449a4 commit a9619ed

62 files changed

Lines changed: 1876 additions & 696 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/polycentric/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"@gorhom/bottom-sheet": "^5.2.8",
2121
"@lodev09/react-native-true-sheet": "^3.0.4",
2222
"@noble/hashes": "catalog:",
23-
"@op-engineering/op-sqlite": "^15.2.5",
2423
"@polycentric/react-native": "workspace:*",
2524
"@react-native-async-storage/async-storage": "^2.2.0",
2625
"@react-navigation/bottom-tabs": "^7.15.4",
@@ -46,6 +45,7 @@
4645
"expo-router": "~55.0.3",
4746
"expo-server": "~55.0.8",
4847
"expo-splash-screen": "~55.0.10",
48+
"expo-sqlite": "~55.0.15",
4949
"expo-status-bar": "~55.0.4",
5050
"expo-symbols": "~55.0.4",
5151
"expo-system-ui": "~55.0.9",

apps/polycentric/src/common/components/primitives/Text.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ const VARIANT_CONFIG: Record<
7777
title: { size: 'xl', defaultWeight: 'bold' },
7878
subtitle: { size: 'lg', defaultWeight: 'semibold' },
7979
body: { size: 'md', defaultWeight: 'regular' },
80-
secondary: { size: 'sm', defaultWeight: 'regular' },
80+
secondary: { size: 'md', defaultWeight: 'regular' },
8181
small: { size: 'xs', defaultWeight: 'semibold' },
8282
} as const;

apps/polycentric/src/common/lib/polycentric-hooks/helpers.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,15 @@ export function timeAgo(unixMs: number): string {
126126
if (mins < 60) return `${mins}m`;
127127
const hours = Math.floor(mins / 60);
128128
if (hours < 24) return `${hours}h`;
129-
return `${Math.floor(hours / 24)}d`;
129+
const days = Math.floor(hours / 24);
130+
if (days < 7) return `${days}d`;
131+
const date = new Date(unixMs);
132+
const sameYear = date.getFullYear() === new Date().getFullYear();
133+
return date.toLocaleDateString(undefined, {
134+
month: 'short',
135+
day: 'numeric',
136+
year: sameYear ? undefined : 'numeric',
137+
});
130138
}
131139

132140
export function bytesToHex(bytes: Uint8Array): string {

apps/polycentric/src/common/lib/polycentric-hooks/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export { useUsername } from './PolycentricProvider';
1212

1313
// Action hooks
1414
export { useCurrentIdentity, useIdentities } from './PolycentricProvider';
15+
export { useIdentityKeyFor } from './useIdentityKeyFor';
1516

1617
// Store
1718
export { useStore } from './store';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { KeyPair } from '@polycentric/react-native';
2+
import { useEffect, useState } from 'react';
3+
import { pubkeyStr } from './helpers';
4+
import { usePolycentricContext } from './PolycentricProvider';
5+
6+
// Needed because client.getIdentityKeyFor is now async and can't be called in render.
7+
export function useIdentityKeyFor(keyPair: KeyPair): string | null {
8+
const { client } = usePolycentricContext();
9+
const pubKey = pubkeyStr(keyPair.publicKey);
10+
const [identityKey, setIdentityKey] = useState<string | null>(null);
11+
useEffect(() => {
12+
let cancelled = false;
13+
void client.getIdentityKeyFor(keyPair).then((k) => {
14+
if (!cancelled) setIdentityKey(k);
15+
});
16+
return () => {
17+
cancelled = true;
18+
};
19+
// eslint-disable-next-line react-hooks/exhaustive-deps
20+
}, [client, pubKey]);
21+
return identityKey;
22+
}

apps/polycentric/src/common/theme/tokens.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { StyleSheet, TextStyle } from 'react-native';
22

33
export const Spacing = {
44
'0': 0,
5+
'2xs': 2,
56
xs: 4,
67
sm: 8,
78
md: 12,
@@ -31,7 +32,7 @@ export const typography = {
3132
fontSize: {
3233
xs: 12,
3334
sm: 14,
34-
md: 17,
35+
md: 15,
3536
lg: 20,
3637
xl: 24,
3738
} as const,
@@ -43,7 +44,7 @@ export const typography = {
4344
lineHeight: {
4445
xs: 16,
4546
sm: 20,
46-
md: 24,
47+
md: 20,
4748
lg: 28,
4849
xl: 32,
4950
} as const,
@@ -250,6 +251,9 @@ export const Atoms = StyleSheet.create({
250251
gap_0: {
251252
gap: Spacing['0'],
252253
},
254+
gap_2xs: {
255+
gap: Spacing['2xs'],
256+
},
253257
gap_xs: {
254258
gap: Spacing.xs,
255259
},

apps/polycentric/src/features/core/identity/IdentitySwitcher.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
pubkeyStr,
1313
useCurrentIdentity,
1414
useIdentities,
15+
useIdentityKeyFor,
1516
usePolycentric,
1617
} from '@/src/common/lib/polycentric-hooks';
1718
import { SheetHeaderBlock, type DismissSheet } from '@/src/common/lib/sheet';
@@ -169,9 +170,9 @@ function IdentityListItemContent({
169170
}) {
170171
const { theme } = useTheme();
171172
const { isEditing } = useIdentitySwitcher();
172-
const { isCurrentIdentity, client } = useCurrentIdentity();
173+
const { isCurrentIdentity } = useCurrentIdentity();
173174

174-
const identityKey = client.getIdentityKeyFor(item);
175+
const identityKey = useIdentityKeyFor(item);
175176
const isCurrent = isCurrentIdentity(identityKey);
176177

177178
const hoverSurface =
@@ -224,11 +225,11 @@ function IdentityListItemContent({
224225
}
225226

226227
function StaticIdentityListItem({ item }: ListRenderItemInfo<IdentityKeyPair>) {
227-
const { isCurrentIdentity, switchIdentity, client } = useCurrentIdentity();
228+
const { isCurrentIdentity, switchIdentity } = useCurrentIdentity();
228229
const { dismiss } = useIdentitySwitcher();
229230
const { hovered, onHoverIn, onHoverOut } = useWebHover();
230231

231-
const identityKey = client.getIdentityKeyFor(item);
232+
const identityKey = useIdentityKeyFor(item);
232233
const isCurrent = isCurrentIdentity(identityKey);
233234

234235
const handleSwitchIdentity = async () => {

apps/polycentric/src/features/post/ConversationView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function ConversationView({ post }: ConversationViewProps) {
4040
<View style={[Atoms.w_full]}>
4141
<Post
4242
post={item}
43-
hideReplyingTo={false}
43+
hideReplyingTo={true}
4444
disablePress={item.id === post.id}
4545
showThreadLineAbove={lineAbove}
4646
showThreadLineBelow={lineBelow}

apps/polycentric/src/features/post/Post.tsx

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export const Post = memo(function Post({
136136
disabled={disablePress}
137137
>
138138
{/* Top padding bar */}
139-
<View style={[Atoms.flex_row, Atoms.gap_lg]}>
139+
<View style={[Atoms.flex_row, Atoms.gap_md]}>
140140
<View
141141
style={[
142142
Atoms.align_center,
@@ -167,7 +167,7 @@ export const Post = memo(function Post({
167167
</View>
168168

169169
{/* Main post body */}
170-
<View style={[Atoms.flex_row, Atoms.gap_lg]}>
170+
<View style={[Atoms.flex_row, Atoms.gap_md]}>
171171
{/* Left side (avatar and thread line) */}
172172
<View style={[Atoms.align_center]}>
173173
{authorIdentity ? (
@@ -195,52 +195,48 @@ export const Post = memo(function Post({
195195
</View>
196196

197197
{/* Main post content */}
198-
<View style={[Atoms.flex_1, Atoms.pb_md]}>
198+
<View style={[Atoms.flex_1, Atoms.pb_md, Atoms.gap_2xs]}>
199199
{/* Author name and other topbar items */}
200-
<View
201-
style={[
202-
Atoms.flex_row,
203-
Atoms.justify_between,
204-
{ alignItems: 'baseline', marginTop: -1 },
205-
]}
206-
>
200+
<View style={[Atoms.flex_row, Atoms.align_center]}>
207201
<View
208202
style={[
209203
Atoms.flex_1,
210204
Atoms.flex_row,
211205
Atoms.gap_xs,
212-
{ alignItems: 'baseline' },
206+
Atoms.align_center,
213207
]}
214208
>
215209
<PostAuthorName
216210
name={authorName || '...'}
217211
onPress={handleAuthorPress}
218212
/>
219213
{authorIdentity ? (
220-
<IdentityTag
221-
identity={authorIdentity}
222-
style={{ transform: [{ translateY: 1 }] }}
223-
/>
214+
<IdentityTag identity={authorIdentity} />
224215
) : null}
225-
</View>
226216

227-
{time ? (
228-
<Text
229-
variant="small"
230-
color="neutral_500"
231-
style={{ lineHeight: 18, marginLeft: 8 }}
232-
>
233-
{time}
234-
</Text>
235-
) : null}
217+
{time ? (
218+
<>
219+
<Text
220+
variant="secondary"
221+
color="neutral_500"
222+
fontWeight="bold"
223+
>
224+
·
225+
</Text>
226+
<Text variant="secondary" color="neutral_500">
227+
{time}
228+
</Text>
229+
</>
230+
) : null}
231+
</View>
236232
</View>
237233

238234
{!hideReplyingTo && post.reply?.parentId ? (
239235
<ReplyingToSubheader parentId={post.reply.parentId} />
240236
) : null}
241237

242238
{displayContent ? (
243-
<Text variant="secondary" style={[Atoms.mt_xs]}>
239+
<Text variant="secondary">
244240
{displayContent}
245241
{isTruncatedPreview ? '...' : ''}
246242
</Text>
@@ -251,7 +247,7 @@ export const Post = memo(function Post({
251247
onPress={toggleContentExpanded}
252248
onHoverIn={onExpandHoverIn}
253249
onHoverOut={onExpandHoverOut}
254-
style={{ marginTop: 2, alignSelf: 'flex-start' }}
250+
style={[Atoms.self_start]}
255251
>
256252
<Text
257253
variant="small"
@@ -272,7 +268,7 @@ export const Post = memo(function Post({
272268
onDislike={handleDislike}
273269
liked={liked}
274270
disliked={disliked}
275-
style={{ marginTop: 8 }}
271+
style={[Atoms.mt_sm]}
276272
/>
277273
</View>
278274
</View>
@@ -302,12 +298,12 @@ function ReplyingToSubheader({ parentId }: { parentId: string }) {
302298
return (
303299
<Pressable
304300
onPress={handlePress}
305-
style={[Atoms.flex_row, Atoms.mt_xs, { alignItems: 'baseline' }]}
301+
style={[Atoms.flex_row, Atoms.align_center]}
306302
>
307-
<Text variant="small" color="neutral_500" fontWeight="regular">
308-
Reply to{' '}
303+
<Text variant="secondary" color="neutral_500" fontWeight="regular">
304+
Replying to{' '}
309305
</Text>
310-
<Text variant="small" color="primary_500">
306+
<Text variant="secondary" color="primary_500">
311307
{truncateName(parentName || '…', 24)}
312308
</Text>
313309
</Pressable>
@@ -328,10 +324,7 @@ function PostAuthorName({
328324
<Text
329325
variant="secondary"
330326
fontWeight="bold"
331-
style={[
332-
{ lineHeight: 18 },
333-
hovered && { textDecorationLine: 'underline' },
334-
]}
327+
style={[hovered && { textDecorationLine: 'underline' }]}
335328
>
336329
{truncateName(name, 16)}
337330
</Text>

packages/js-browser/src/storage/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)