Skip to content

Commit cfc43ed

Browse files
committed
Merge branch 'mh/delete-posts' into 'develop'
Delete posts See merge request polycentric/polycentric!523
2 parents 70461e0 + 00615cb commit cfc43ed

102 files changed

Lines changed: 4489 additions & 1735 deletions

File tree

Some content is hidden

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

.gitlab/images/rust/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y \
1111

1212
# Rust deps
1313
RUN rustup set profile default && rustup component add clippy rustfmt
14-
RUN cargo install just wasm-bindgen-cli cargo-ndk && rm -rf /usr/local/cargo/registry
14+
RUN cargo install just cargo-ndk && rm -rf /usr/local/cargo/registry
1515

1616
# Android NDK
1717
RUN curl -L -o /tmp/ndk.zip "https://dl.google.com/android/repository/android-ndk-r27c-linux.zip" \

apps/polycentric/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@react-navigation/bottom-tabs": "^7.15.4",
2727
"@react-navigation/elements": "^2.8.0",
2828
"@react-navigation/native": "^7.1.32",
29+
"@rn-primitives/dropdown-menu": "^1.4.0",
2930
"@shopify/flash-list": "^2.3.1",
3031
"@types/react-native-web": "^0.19.2",
3132
"better-sqlite3": "^12.6.2",
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import * as DropdownMenuPrimitive from '@rn-primitives/dropdown-menu';
2+
import React, { ReactNode, useState } from 'react';
3+
import { View } from 'react-native';
4+
5+
import { Atoms, useTheme } from '../theme';
6+
7+
function DropdownMenuContent({
8+
style,
9+
...props
10+
}: DropdownMenuPrimitive.ContentProps &
11+
React.RefAttributes<DropdownMenuPrimitive.ContentRef>) {
12+
const { theme } = useTheme();
13+
14+
return (
15+
<DropdownMenuPrimitive.Portal>
16+
<DropdownMenuPrimitive.Overlay>
17+
<DropdownMenuPrimitive.Content
18+
style={(state) => [
19+
{ borderWidth: 1, borderColor: theme.palette.neutral_50 },
20+
Atoms.rounded_lg,
21+
{ minWidth: 256 },
22+
//Atoms.outline_none,
23+
{ backgroundColor: theme.palette.neutral_25 },
24+
Atoms.overflow_hidden,
25+
typeof style === 'function' ? style(state) : style,
26+
]}
27+
{...props}
28+
/>
29+
</DropdownMenuPrimitive.Overlay>
30+
</DropdownMenuPrimitive.Portal>
31+
);
32+
}
33+
34+
function DropdownMenuItem({
35+
style,
36+
children,
37+
...props
38+
}: DropdownMenuPrimitive.ItemProps & { children: ReactNode }) {
39+
const { theme } = useTheme();
40+
const [hovered, setHovering] = useState(false);
41+
42+
return (
43+
<DropdownMenuPrimitive.Item
44+
style={{ outline: 'none' }}
45+
onHoverIn={() => setHovering(true)}
46+
onHoverOut={() => setHovering(false)}
47+
{...props}
48+
>
49+
<View
50+
style={[
51+
Atoms.py_md,
52+
Atoms.px_lg,
53+
hovered && { backgroundColor: theme.palette.neutral_50 },
54+
Atoms.flex_row,
55+
Atoms.align_center,
56+
Atoms.gap_lg,
57+
]}
58+
>
59+
{children}
60+
</View>
61+
</DropdownMenuPrimitive.Item>
62+
);
63+
}
64+
65+
function DropdownMenu({ children }: { children: ReactNode }) {
66+
return <DropdownMenuPrimitive.Root>{children}</DropdownMenuPrimitive.Root>;
67+
}
68+
DropdownMenu.Trigger = DropdownMenuPrimitive.Trigger;
69+
DropdownMenu.Content = DropdownMenuContent;
70+
DropdownMenu.Item = DropdownMenuItem;
71+
72+
export default DropdownMenu;

apps/polycentric/src/common/components/List/List.tsx renamed to apps/polycentric/src/common/components/List.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Animated, {
2020
useAnimatedStyle,
2121
useSharedValue,
2222
} from 'react-native-reanimated';
23-
import { Atoms } from '../../theme';
23+
import { Atoms } from '../theme';
2424

2525
// A reanimated-compatible FlashList.
2626
const AnimatedFlashList = Animated.createAnimatedComponent(FlashList);

apps/polycentric/src/common/components/TextArea/TextArea.tsx renamed to apps/polycentric/src/common/components/TextArea.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
useRef,
66
} from 'react';
77
import { Platform, TextInput as RNTextInput } from 'react-native';
8-
import { TextInput, type TextInputProps } from '../primitives/TextInput';
8+
import { TextInput, type TextInputProps } from './primitives/TextInput';
99

1010
export interface TextAreaProps extends Omit<TextInputProps, 'multiline'> {
1111
/** Minimum height in pixels. Defaults to 40. */

apps/polycentric/src/common/components/primitives/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export * from '../Avatar/Avatar';
22
export * from '../Avatar/ProfileAvatar';
3-
export * from '../TextArea/TextArea';
3+
export * from '../TextArea';
44
export * from './Button';
55
export * from './Chip';
66
export * from './HorizontalScrollGroup';

apps/polycentric/src/common/constants/routes.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@ import { PostData } from '../lib/polycentric-hooks';
33

44
export type OpenComposeOptions = {
55
replyTo?: PostData['id'];
6+
quote?: PostData['id'];
67
/** Immediately launch the image picker once the composer mounts. */
78
attachImage?: boolean;
89
};
910

1011
export function openCompose(options: OpenComposeOptions = {}) {
11-
const { replyTo, attachImage } = options;
12+
const { replyTo, quote, attachImage } = options;
1213
const params = new URLSearchParams();
1314
if (replyTo) {
1415
params.set('replyTo', replyTo);
1516
}
17+
if (quote) {
18+
params.set('quote', quote);
19+
}
1620
if (attachImage) params.set('attach', '1');
17-
const qs = params.toString();
21+
const queryString = params.toString();
1822
router.push(
19-
qs ? `${Routes.tabs.feed.compose}?${qs}` : Routes.tabs.feed.compose,
23+
queryString
24+
? `${Routes.tabs.feed.compose}?${queryString}`
25+
: Routes.tabs.feed.compose,
2026
);
2127
}
2228

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export type PostData = {
3535
parentId?: string;
3636
};
3737

38+
/** Hex of the quoted post's EventKey — same encoding as `PostData.id`. */
39+
quoteId?: string;
40+
3841
signedEvent: v2.SignedEvent;
3942
};
4043

@@ -74,6 +77,9 @@ export function decodePostBundle(bundle: v2.EventBundle): PostData | null {
7477
: undefined,
7578
}
7679
: undefined;
80+
const quoteId = post.quote
81+
? bytesToHex(v2.EventKey.toBinary(post.quote))
82+
: undefined;
7783

7884
return {
7985
id,
@@ -84,6 +90,7 @@ export function decodePostBundle(bundle: v2.EventBundle): PostData | null {
8490
createdAt: Number(event.createdAt ?? 0),
8591
images: post.images,
8692
reply,
93+
quoteId,
8794
signedEvent: v2.SignedEvent.create({
8895
eventBytes: bundle.signedEvent.eventBytes,
8996
signature: bundle.signedEvent.signature,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Alert } from 'react-native';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { AlertButton, AlertStatic } from 'react-native';
2+
3+
class AlertWeb implements Pick<AlertStatic, 'alert'> {
4+
public alert(title: string, message?: string, buttons?: AlertButton[]): void {
5+
if (buttons === undefined || buttons.length === 0) {
6+
window.alert([title, message].filter(Boolean).join('\n'));
7+
return;
8+
}
9+
10+
const result = window.confirm([title, message].filter(Boolean).join('\n'));
11+
12+
if (result === true) {
13+
const confirm = buttons.find(({ style }) => style !== 'cancel');
14+
confirm?.onPress?.();
15+
return;
16+
}
17+
18+
const cancel = buttons.find(({ style }) => style === 'cancel');
19+
cancel?.onPress?.();
20+
}
21+
}
22+
export const Alert = new AlertWeb();

0 commit comments

Comments
 (0)