@openpeepshq/rn-components 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/components/jams/JamDeviceSelectors.tsx +31 -3
- package/src/components/jams/JamLobby.tsx +104 -5
- package/src/components/jams/JamVideoCall.tsx +157 -3
- package/src/components/jams/JamVideoLayout.tsx +9 -2
- package/src/components/jams/useLateTrackMediaStream.test.ts +145 -0
- package/src/components/jams/useLateTrackMediaStream.ts +61 -0
- package/src/components/post/feed/events/EventsCalendar.test.tsx +144 -0
- package/src/components/post/feed/events/EventsCalendar.tsx +4 -8
- package/src/components/post/feed/events/EventsView.tsx +5 -13
- package/src/components/post/post-form/OpenpeepsMarkdownInput.tsx +14 -5
- package/src/components/post/post-form/PostForm.tsx +1 -0
- package/src/lib/dmMessageGate.test.ts +58 -0
- package/src/lib/livekit/useStableLiveKitRoom.ts +23 -13
- package/src/lib/utils.ts +4 -1
- package/src/pages/conversations/NewDraft.tsx +2 -3
- package/src/pages/conversations/Show.tsx +4 -1
- package/src/pages/events/Index.tsx +1 -5
- package/src/pages/events/My.tsx +1 -2
- package/src/pages/groups/Show.tsx +10 -2
- package/src/pages/posts/Edit.tsx +16 -6
- package/src/pages/posts/New.tsx +15 -5
- package/src/pages/posts/Reply.tsx +15 -6
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RN parity lock (issue #2131), updated for issue #2128: the native
|
|
3
|
+
* EventsCalendar must render exactly what the shared `useEventsCalendar` hook
|
|
4
|
+
* from `@openpeepshq/react` returns — the single source of truth, with no
|
|
5
|
+
* separate RN implementation. Since #2128 the hook is a date-range calendar:
|
|
6
|
+
* it reads one row per occurrence from the server's month-window range feed
|
|
7
|
+
* and buckets the rows by browser-local day keys. The mock below emulates
|
|
8
|
+
* that contract — it returns the rows for the selected day only, and an event
|
|
9
|
+
* the range feed did not return must not appear. If the native component ever
|
|
10
|
+
* rendered events from any other source (a query of its own, its own
|
|
11
|
+
* filtering), these assertions fail.
|
|
12
|
+
*
|
|
13
|
+
* `@openpeepshq/react` is mocked because the package's jest transform only
|
|
14
|
+
* covers this package — the same pattern every RN test here uses.
|
|
15
|
+
*/
|
|
16
|
+
import React from 'react';
|
|
17
|
+
import ReactTestRenderer from 'react-test-renderer';
|
|
18
|
+
import type { PublicPost } from '@openpeepshq/common/types';
|
|
19
|
+
|
|
20
|
+
// --- react-native: host elements render as plain host tags ----------------
|
|
21
|
+
jest.mock('react-native', () => {
|
|
22
|
+
const React = require('react');
|
|
23
|
+
const make =
|
|
24
|
+
(tag: string) =>
|
|
25
|
+
(props: { children?: React.ReactNode; onPress?: () => void }) =>
|
|
26
|
+
React.createElement(tag, { onPress: props.onPress }, props.children);
|
|
27
|
+
return {
|
|
28
|
+
View: make('View'),
|
|
29
|
+
Pressable: make('Pressable'),
|
|
30
|
+
ActivityIndicator: () => null,
|
|
31
|
+
ScrollView: make('ScrollView'),
|
|
32
|
+
RefreshControl: () => null,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
jest.mock('@react-navigation/native', () => ({
|
|
37
|
+
useNavigation: () => ({ navigate: jest.fn() }),
|
|
38
|
+
useFocusEffect: jest.fn(),
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
jest.mock('react-i18next', () => ({
|
|
42
|
+
useTranslation: () => ({
|
|
43
|
+
t: (_key: string, opts?: { defaultValue?: string }) =>
|
|
44
|
+
opts?.defaultValue ?? _key,
|
|
45
|
+
}),
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
jest.mock('../../../../theme/useThemeOpacity', () => ({
|
|
49
|
+
useThemeOpacity: () => ({ background: () => ({}) }),
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
jest.mock('../../../navigation/types/index', () => ({
|
|
53
|
+
MainStackParamList: {},
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
jest.mock('../../../../lib/utils', () => ({
|
|
57
|
+
cn: (...args: unknown[]) => args.filter(Boolean).join(' '),
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
jest.mock('../../../ui/themed-text', () => ({
|
|
61
|
+
ThemedText: (props: Record<string, unknown>) =>
|
|
62
|
+
React.createElement('Text', props, props.children),
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
jest.mock('../../../icons/index', () => ({
|
|
66
|
+
ChevronLeftIcon: () => null,
|
|
67
|
+
ChevronRightIcon: () => null,
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
// --- shared hook contract: one row per occurrence, bucketed by local day ---
|
|
71
|
+
const future = {
|
|
72
|
+
id: 'future-event',
|
|
73
|
+
data: {
|
|
74
|
+
type: 'event',
|
|
75
|
+
name: 'future-event',
|
|
76
|
+
start: '2026-11-19T10:00:00.000Z',
|
|
77
|
+
end: '2026-11-19T11:00:00.000Z',
|
|
78
|
+
wholeDay: false,
|
|
79
|
+
},
|
|
80
|
+
} as unknown as PublicPost;
|
|
81
|
+
|
|
82
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
83
|
+
useEventsCalendar: () => ({
|
|
84
|
+
cells: [
|
|
85
|
+
{ key: '2026-11-18', inMonth: true },
|
|
86
|
+
{ key: '2026-11-19', inMonth: true },
|
|
87
|
+
],
|
|
88
|
+
byDay: new Map([['2026-11-19', [future]]]),
|
|
89
|
+
todayKey: '2026-11-18',
|
|
90
|
+
selected: '2026-11-19',
|
|
91
|
+
selectedEvents: [future],
|
|
92
|
+
selectedLabel: 'Selected day',
|
|
93
|
+
setSelectedKey: () => undefined,
|
|
94
|
+
monthLabel: 'Parity month',
|
|
95
|
+
weekdayLabels: ['S', 'M'],
|
|
96
|
+
isLoading: false,
|
|
97
|
+
isFetchingNextPage: false,
|
|
98
|
+
shiftMonth: () => undefined,
|
|
99
|
+
goToday: () => undefined,
|
|
100
|
+
}),
|
|
101
|
+
calendarDayNumber: (key: string) => key,
|
|
102
|
+
calendarEventName: (post: PublicPost) =>
|
|
103
|
+
post.data.type === 'event' ? (post.data.name ?? '') : '',
|
|
104
|
+
eventStartIso: (post: PublicPost) =>
|
|
105
|
+
post.occurrenceStart ?? (post.data as { start?: string }).start,
|
|
106
|
+
eventEndIso: (post: PublicPost) =>
|
|
107
|
+
post.occurrenceEnd ?? (post.data as { end?: string }).end,
|
|
108
|
+
}));
|
|
109
|
+
|
|
110
|
+
import { EventsCalendar } from './EventsCalendar';
|
|
111
|
+
|
|
112
|
+
const renderCalendar = async (props: Record<string, unknown> = {}) => {
|
|
113
|
+
jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
|
114
|
+
jest.spyOn(console, 'warn').mockImplementation(() => undefined);
|
|
115
|
+
const renderer = ReactTestRenderer.create(<EventsCalendar {...props} />);
|
|
116
|
+
await ReactTestRenderer.act(async () => undefined);
|
|
117
|
+
return renderer;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
describe('EventsCalendar (native) shared-hook parity', () => {
|
|
121
|
+
it('renders the shared hook output through the scope prop', async () => {
|
|
122
|
+
const renderer = await renderCalendar({});
|
|
123
|
+
const tree = renderer.toJSON();
|
|
124
|
+
expect(tree).not.toBeNull();
|
|
125
|
+
const text = JSON.stringify(tree);
|
|
126
|
+
expect(text).toContain('Parity month');
|
|
127
|
+
expect(text).toContain('Selected day');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('shows the range-feed row on the selected day list', async () => {
|
|
131
|
+
const renderer = await renderCalendar({});
|
|
132
|
+
const text = JSON.stringify(renderer.toJSON());
|
|
133
|
+
expect(text).toContain('future-event');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('never shows an event the shared hook did not return', async () => {
|
|
137
|
+
const renderer = await renderCalendar({});
|
|
138
|
+
const text = JSON.stringify(renderer.toJSON());
|
|
139
|
+
// The component has no query of its own; anything it shows came from the
|
|
140
|
+
// hook's `selectedEvents`. An event absent from that list must not leak
|
|
141
|
+
// into the grid or the day list.
|
|
142
|
+
expect(text).not.toContain('past-event');
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -10,8 +10,7 @@ import {
|
|
|
10
10
|
eventEndIso,
|
|
11
11
|
eventStartIso,
|
|
12
12
|
useEventsCalendar,
|
|
13
|
-
type
|
|
14
|
-
type EventsCalendarQuery,
|
|
13
|
+
type CalendarScopeProps,
|
|
15
14
|
} from '@openpeepshq/react';
|
|
16
15
|
import { ChevronLeftIcon, ChevronRightIcon } from '../../../icons/index';
|
|
17
16
|
import { useThemeOpacity } from '../../../../theme/useThemeOpacity';
|
|
@@ -19,15 +18,12 @@ import { MainStackParamList } from '../../../navigation/types/index';
|
|
|
19
18
|
import { ThemedText } from '../../../ui/themed-text';
|
|
20
19
|
import { cn } from '../../../../lib/utils';
|
|
21
20
|
|
|
22
|
-
export
|
|
23
|
-
query: EventsCalendarQuery;
|
|
24
|
-
agenda: EventsAgendaWindow;
|
|
25
|
-
}
|
|
21
|
+
export type EventsCalendarProps = CalendarScopeProps;
|
|
26
22
|
|
|
27
23
|
const postKey = (post: PublicPost) =>
|
|
28
24
|
`${post.id}:${post.occurrenceRecurrenceId ?? ''}`;
|
|
29
25
|
|
|
30
|
-
export const EventsCalendar = (
|
|
26
|
+
export const EventsCalendar = (props: EventsCalendarProps) => {
|
|
31
27
|
const { t } = useTranslation();
|
|
32
28
|
const { background } = useThemeOpacity();
|
|
33
29
|
const navigation =
|
|
@@ -46,7 +42,7 @@ export const EventsCalendar = ({ query, agenda }: EventsCalendarProps) => {
|
|
|
46
42
|
isFetchingNextPage,
|
|
47
43
|
shiftMonth,
|
|
48
44
|
goToday,
|
|
49
|
-
} = useEventsCalendar(
|
|
45
|
+
} = useEventsCalendar(props);
|
|
50
46
|
|
|
51
47
|
const openEvent = (post: PublicPost) =>
|
|
52
48
|
navigation.navigate('Post', {
|
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
useEventView,
|
|
5
|
-
type EventsAgendaWindow,
|
|
6
|
-
type EventsCalendarQuery,
|
|
7
|
-
} from '@openpeepshq/react';
|
|
3
|
+
import { useEventView, type CalendarScopeProps } from '@openpeepshq/react';
|
|
8
4
|
import { EventViewSwitch } from '../../EventViewSwitch';
|
|
9
5
|
import { EventsCalendar } from './EventsCalendar';
|
|
10
6
|
|
|
11
7
|
export interface EventsViewProps {
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
/** Scope for calendar — lists don't use this. */
|
|
9
|
+
calendar?: CalendarScopeProps;
|
|
14
10
|
list: ReactNode;
|
|
15
11
|
}
|
|
16
12
|
|
|
17
13
|
/** List (the existing layout) or a month calendar, shared across event pages. */
|
|
18
|
-
export const EventsView = ({
|
|
14
|
+
export const EventsView = ({ calendar, list }: EventsViewProps) => {
|
|
19
15
|
const { view } = useEventView();
|
|
20
16
|
return (
|
|
21
17
|
<View className="flex-1">
|
|
22
18
|
<EventViewSwitch />
|
|
23
|
-
{view === 'calendar' ? (
|
|
24
|
-
<EventsCalendar key={agenda} query={query} agenda={agenda} />
|
|
25
|
-
) : (
|
|
26
|
-
list
|
|
27
|
-
)}
|
|
19
|
+
{view === 'calendar' ? <EventsCalendar {...(calendar ?? {})} /> : list}
|
|
28
20
|
</View>
|
|
29
21
|
);
|
|
30
22
|
};
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type NativeSyntheticEvent,
|
|
8
8
|
type TextInputSelectionChangeEventData,
|
|
9
9
|
} from 'react-native';
|
|
10
|
-
import type
|
|
10
|
+
import { visibleTextLength, type PublicProfile } from '@openpeepshq/common';
|
|
11
11
|
import { useOpenpeeps } from '@openpeepshq/react';
|
|
12
12
|
import { useTranslation } from 'react-i18next';
|
|
13
13
|
import { OpenpeepsMarkdown } from '../../markdown/index';
|
|
@@ -21,8 +21,13 @@ import { cn, maxContentLength } from '../../../lib/utils';
|
|
|
21
21
|
export interface OpenpeepsMarkdownInputProps {
|
|
22
22
|
value: string;
|
|
23
23
|
onChange: (value: string) => void;
|
|
24
|
-
/**
|
|
24
|
+
/** Visible-text character budget; the counter turns red once exceeded. */
|
|
25
25
|
maxLength?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Hard-stop typing at the budget. For forms that do not validate the
|
|
28
|
+
* length on submit.
|
|
29
|
+
*/
|
|
30
|
+
blockOverflow?: boolean;
|
|
26
31
|
placeholder?: string;
|
|
27
32
|
rows?: number;
|
|
28
33
|
/** Show the preview toggle button (mirrors web `previewButton`). */
|
|
@@ -47,6 +52,7 @@ export const OpenpeepsMarkdownInput = ({
|
|
|
47
52
|
value,
|
|
48
53
|
onChange,
|
|
49
54
|
maxLength = maxContentLength,
|
|
55
|
+
blockOverflow = true,
|
|
50
56
|
placeholder,
|
|
51
57
|
rows = 5,
|
|
52
58
|
previewButton = true,
|
|
@@ -134,7 +140,10 @@ export const OpenpeepsMarkdownInput = ({
|
|
|
134
140
|
}
|
|
135
141
|
};
|
|
136
142
|
|
|
137
|
-
|
|
143
|
+
// With the native cap on (blockOverflow) the counter tracks the raw length
|
|
144
|
+
// it enforces; otherwise it tracks the visible text the submit check uses.
|
|
145
|
+
const shownLength = blockOverflow ? value.length : visibleTextLength(value);
|
|
146
|
+
const overLimit = shownLength > maxLength;
|
|
138
147
|
|
|
139
148
|
return (
|
|
140
149
|
<View className="relative w-full">
|
|
@@ -203,7 +212,7 @@ export const OpenpeepsMarkdownInput = ({
|
|
|
203
212
|
autoFocus={autoFocus}
|
|
204
213
|
numberOfLines={rows}
|
|
205
214
|
value={value}
|
|
206
|
-
maxLength={maxLength}
|
|
215
|
+
maxLength={blockOverflow ? maxLength : undefined}
|
|
207
216
|
placeholder={placeholder ?? t('posts.form.content')}
|
|
208
217
|
onChangeText={handleChange}
|
|
209
218
|
onSelectionChange={handleSelectionChange}
|
|
@@ -217,7 +226,7 @@ export const OpenpeepsMarkdownInput = ({
|
|
|
217
226
|
<ThemedText
|
|
218
227
|
className={cn('text-right text-sm', overLimit && 'text-destructive')}
|
|
219
228
|
>
|
|
220
|
-
{
|
|
229
|
+
{shownLength} / {maxLength}
|
|
221
230
|
</ThemedText>
|
|
222
231
|
</View>
|
|
223
232
|
</View>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { canSendDmMessage } from '../../../react/src/hooks/conversations/dmMessage';
|
|
2
|
+
import {
|
|
3
|
+
hasVisibleText,
|
|
4
|
+
POST_MAX_VISIBLE_LENGTH,
|
|
5
|
+
visibleTextLength,
|
|
6
|
+
} from '@openpeepshq/common';
|
|
7
|
+
|
|
8
|
+
const attachments: never[] = [];
|
|
9
|
+
|
|
10
|
+
describe('DM visible-length send gate', () => {
|
|
11
|
+
it('shares the note budget with the server refine', () => {
|
|
12
|
+
expect(POST_MAX_VISIBLE_LENGTH).toBe(500);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('blocks a message whose visible text is over the budget', () => {
|
|
16
|
+
const text = 'x'.repeat(POST_MAX_VISIBLE_LENGTH + 1);
|
|
17
|
+
expect(visibleTextLength(text)).toBeGreaterThan(POST_MAX_VISIBLE_LENGTH);
|
|
18
|
+
expect(
|
|
19
|
+
canSendDmMessage({
|
|
20
|
+
sending: false,
|
|
21
|
+
uploadsPending: false,
|
|
22
|
+
text,
|
|
23
|
+
attachments,
|
|
24
|
+
})
|
|
25
|
+
).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('allows a markdown link whose URL alone is longer than the budget', () => {
|
|
29
|
+
const text =
|
|
30
|
+
'[a long but visibly short link](https://example.com/' +
|
|
31
|
+
'y'.repeat(600) +
|
|
32
|
+
')';
|
|
33
|
+
expect(text.length).toBeGreaterThan(POST_MAX_VISIBLE_LENGTH);
|
|
34
|
+
expect(visibleTextLength(text)).toBeLessThanOrEqual(
|
|
35
|
+
POST_MAX_VISIBLE_LENGTH
|
|
36
|
+
);
|
|
37
|
+
expect(
|
|
38
|
+
canSendDmMessage({
|
|
39
|
+
sending: false,
|
|
40
|
+
uploadsPending: false,
|
|
41
|
+
text,
|
|
42
|
+
attachments,
|
|
43
|
+
})
|
|
44
|
+
).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('blocks whitespace-only text without attachments', () => {
|
|
48
|
+
expect(hasVisibleText(' \n ')).toBe(false);
|
|
49
|
+
expect(
|
|
50
|
+
canSendDmMessage({
|
|
51
|
+
sending: false,
|
|
52
|
+
uploadsPending: false,
|
|
53
|
+
text: ' \n ',
|
|
54
|
+
attachments,
|
|
55
|
+
})
|
|
56
|
+
).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -33,6 +33,8 @@ export function useStableLiveKitRoom(
|
|
|
33
33
|
kind?: string
|
|
34
34
|
) => void;
|
|
35
35
|
onEncryptionError?: (error: Error) => void;
|
|
36
|
+
/** Runs after the signal connection, before tracks are enabled. */
|
|
37
|
+
onSignalConnected?: () => void | Promise<void>;
|
|
36
38
|
simulateParticipants?: number;
|
|
37
39
|
}
|
|
38
40
|
): void {
|
|
@@ -49,6 +51,7 @@ export function useStableLiveKitRoom(
|
|
|
49
51
|
onError,
|
|
50
52
|
onMediaDeviceFailure,
|
|
51
53
|
onEncryptionError,
|
|
54
|
+
onSignalConnected,
|
|
52
55
|
simulateParticipants,
|
|
53
56
|
} = params;
|
|
54
57
|
|
|
@@ -59,23 +62,30 @@ export function useStableLiveKitRoom(
|
|
|
59
62
|
connectOptionsRef.current = connectOptions;
|
|
60
63
|
const connectOptionsKey = JSON.stringify(connectOptions);
|
|
61
64
|
|
|
65
|
+
// Callers typically pass a fresh handler object literal on every render;
|
|
66
|
+
// keep a stable ref so the wiring effect does not resubscribe each render.
|
|
67
|
+
const onSignalConnectedRef = React.useRef(onSignalConnected);
|
|
68
|
+
onSignalConnectedRef.current = onSignalConnected;
|
|
69
|
+
|
|
62
70
|
React.useEffect(() => {
|
|
63
71
|
const onSignalConnected = () => {
|
|
64
72
|
const localP = room.localParticipant;
|
|
65
73
|
|
|
66
|
-
Promise.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
void Promise.resolve(onSignalConnectedRef.current?.()).then(() => {
|
|
75
|
+
Promise.all([
|
|
76
|
+
localP.setMicrophoneEnabled(
|
|
77
|
+
!!audio,
|
|
78
|
+
typeof audio !== 'boolean' ? audio : undefined
|
|
79
|
+
),
|
|
80
|
+
localP.setCameraEnabled(
|
|
81
|
+
!!video,
|
|
82
|
+
typeof video !== 'boolean' ? video : undefined
|
|
83
|
+
),
|
|
84
|
+
// Screen share (and its capture permission) is disabled in React Native jams.
|
|
85
|
+
// localP.setScreenShareEnabled(!!screen, typeof screen !== 'boolean' ? screen : undefined),
|
|
86
|
+
]).catch((e: unknown) => {
|
|
87
|
+
onError?.(e as Error);
|
|
88
|
+
});
|
|
79
89
|
});
|
|
80
90
|
};
|
|
81
91
|
|
package/src/lib/utils.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { twMerge } from 'tailwind-merge';
|
|
|
3
3
|
import { lightFormat, parse, parseJSON } from 'date-fns';
|
|
4
4
|
import {
|
|
5
5
|
GroupData,
|
|
6
|
+
POST_MAX_VISIBLE_LENGTH,
|
|
6
7
|
Profile,
|
|
7
8
|
PublicProfile,
|
|
8
9
|
SuccessFailureResponse,
|
|
@@ -21,7 +22,9 @@ const DATE_FORMAT = 'MM/dd/yyyy';
|
|
|
21
22
|
const TIME_FORMAT = 'hh:mm aaa';
|
|
22
23
|
const DATE_TIME_FORMAT = `${DATE_FORMAT} ${TIME_FORMAT}`;
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
// DM/post composer budget — sourced from the shared note budget so the RN
|
|
26
|
+
// default and the server-side refine can never drift apart.
|
|
27
|
+
export const maxContentLength = POST_MAX_VISIBLE_LENGTH;
|
|
25
28
|
export const maxArticleContentLength = 10000;
|
|
26
29
|
|
|
27
30
|
export const formatDateTime = (date: Date) =>
|
|
@@ -115,6 +115,7 @@ export const DraftMessage = ({ navigation }: DraftMessageProps) => {
|
|
|
115
115
|
) : null}
|
|
116
116
|
<OpenpeepsMarkdownInput
|
|
117
117
|
rows={5}
|
|
118
|
+
blockOverflow={false}
|
|
118
119
|
value={message}
|
|
119
120
|
onChange={setMessage}
|
|
120
121
|
maxLength={maxContentLength}
|
|
@@ -135,10 +136,8 @@ export const DraftMessage = ({ navigation }: DraftMessageProps) => {
|
|
|
135
136
|
</Button>
|
|
136
137
|
<TouchableOpacity
|
|
137
138
|
onPress={() => void send()}
|
|
139
|
+
className={`p-2 rounded-full ${canSend ? 'bg-primary' : 'bg-surface'}`}
|
|
138
140
|
disabled={!canSend}
|
|
139
|
-
className={`p-2 rounded-full ${
|
|
140
|
-
canSend ? 'bg-primary' : 'bg-surface'
|
|
141
|
-
}`}
|
|
142
141
|
>
|
|
143
142
|
{submitting ? (
|
|
144
143
|
<ActivityIndicator size={'small'} />
|
|
@@ -147,7 +147,9 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
147
147
|
}, []);
|
|
148
148
|
|
|
149
149
|
const handleSendMessage = async () => {
|
|
150
|
-
if (!canSend)
|
|
150
|
+
if (!canSend) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
151
153
|
|
|
152
154
|
try {
|
|
153
155
|
setIsSending(true);
|
|
@@ -367,6 +369,7 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
367
369
|
<View className="px-4 py-3 bg-background border-t border-border">
|
|
368
370
|
<OpenpeepsMarkdownInput
|
|
369
371
|
rows={3}
|
|
372
|
+
blockOverflow={false}
|
|
370
373
|
value={content}
|
|
371
374
|
onChange={setContent}
|
|
372
375
|
maxLength={maxContentLength}
|
|
@@ -88,11 +88,7 @@ export const EventsIndex = ({
|
|
|
88
88
|
},
|
|
89
89
|
]}
|
|
90
90
|
/>
|
|
91
|
-
<EventsView
|
|
92
|
-
query={activeQuery}
|
|
93
|
-
agenda={tab}
|
|
94
|
-
list={<EventsFeed query={activeQuery} />}
|
|
95
|
-
/>
|
|
91
|
+
<EventsView list={<EventsFeed query={activeQuery} />} />
|
|
96
92
|
<NewEventButton visibility={visibility} currentProfile={currentProfile} />
|
|
97
93
|
</ThemedView>
|
|
98
94
|
);
|
package/src/pages/events/My.tsx
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
} from '../../components/navigation/types/index';
|
|
25
25
|
import {
|
|
26
26
|
EventsFeed,
|
|
27
|
+
EventsView,
|
|
27
28
|
NewEventButton,
|
|
28
29
|
NewNoteButton,
|
|
29
30
|
NewResourceButton,
|
|
@@ -172,8 +173,15 @@ export const GroupShow = ({ route, navigation }: GroupProps) => {
|
|
|
172
173
|
</ThemedText>
|
|
173
174
|
</Pressable>
|
|
174
175
|
</View>
|
|
175
|
-
<
|
|
176
|
-
|
|
176
|
+
<EventsView
|
|
177
|
+
calendar={{ groupId: group.id }}
|
|
178
|
+
list={
|
|
179
|
+
<EventsFeed
|
|
180
|
+
query={
|
|
181
|
+
eventsTab === 'upcoming' ? upcomingEvents : pastEvents
|
|
182
|
+
}
|
|
183
|
+
/>
|
|
184
|
+
}
|
|
177
185
|
/>
|
|
178
186
|
</TabsContent>
|
|
179
187
|
<TabsContent value="resources" className="p-0">
|
package/src/pages/posts/Edit.tsx
CHANGED
|
@@ -7,10 +7,12 @@ import { PostForm } from '../../components/post/post-form/PostForm';
|
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
import { MainScreenProps } from '../../components/navigation/types/index';
|
|
9
9
|
import {
|
|
10
|
-
PostCreationData,
|
|
11
10
|
pollOptionsWithinLimit,
|
|
11
|
+
PostCreationData,
|
|
12
12
|
postCreationDataSchema,
|
|
13
|
+
canSubmitPostContent,
|
|
13
14
|
resolvePollOptionContents,
|
|
15
|
+
visibleTextLength,
|
|
14
16
|
} from '@openpeepshq/common';
|
|
15
17
|
import { ActivityIndicator } from 'react-native';
|
|
16
18
|
import { useForm } from 'react-hook-form';
|
|
@@ -47,6 +49,7 @@ export const EditPost = ({ route, navigation }: PostProps) => {
|
|
|
47
49
|
const attachmentsProcessing = hasProcessingAttachments(postData);
|
|
48
50
|
|
|
49
51
|
const trimmedContent = (postData?.data.content ?? '').trim();
|
|
52
|
+
const visibleContentLength = visibleTextLength(trimmedContent);
|
|
50
53
|
const pollOptions =
|
|
51
54
|
postData?.data.type === 'question'
|
|
52
55
|
? postData.data.options.map((option) => option.content)
|
|
@@ -63,21 +66,28 @@ export const EditPost = ({ route, navigation }: PostProps) => {
|
|
|
63
66
|
return false;
|
|
64
67
|
}
|
|
65
68
|
if (postData.data.type === 'question') {
|
|
66
|
-
return
|
|
69
|
+
return canSubmitPostContent({
|
|
70
|
+
visibleContentLength,
|
|
71
|
+
attachmentsLength: postData.data.attachments?.length ?? 0,
|
|
72
|
+
composerType: 'question',
|
|
73
|
+
pollOptionsValid,
|
|
74
|
+
});
|
|
67
75
|
}
|
|
68
76
|
if (postData.type === 'article') {
|
|
69
77
|
return trimmedContent.length > 0;
|
|
70
78
|
}
|
|
71
|
-
return (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
return canSubmitPostContent({
|
|
80
|
+
visibleContentLength,
|
|
81
|
+
attachmentsLength: postData.data.attachments?.length ?? 0,
|
|
82
|
+
composerType: 'note',
|
|
83
|
+
});
|
|
75
84
|
}, [
|
|
76
85
|
attachmentsProcessing,
|
|
77
86
|
isPosting,
|
|
78
87
|
pollOptionsValid,
|
|
79
88
|
postData,
|
|
80
89
|
trimmedContent.length,
|
|
90
|
+
visibleContentLength,
|
|
81
91
|
]);
|
|
82
92
|
|
|
83
93
|
const handlePostUpdate = async () => {
|
package/src/pages/posts/New.tsx
CHANGED
|
@@ -26,8 +26,10 @@ import {
|
|
|
26
26
|
MediaAttachment,
|
|
27
27
|
pollOptionsWithinLimit,
|
|
28
28
|
PostCreationData,
|
|
29
|
+
canSubmitPostContent,
|
|
29
30
|
resolvePollOptionContents,
|
|
30
31
|
VisibilityType,
|
|
32
|
+
visibleTextLength,
|
|
31
33
|
} from '@openpeepshq/common';
|
|
32
34
|
import { CompositeScreenProps } from '@react-navigation/native';
|
|
33
35
|
import Toast from 'react-native-toast-message';
|
|
@@ -89,6 +91,7 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
89
91
|
canNotify && isCommunityWideVisibility(postData.visibility);
|
|
90
92
|
|
|
91
93
|
const trimmedContent = (postData.data.content ?? '').trim();
|
|
94
|
+
const visibleContentLength = visibleTextLength(trimmedContent);
|
|
92
95
|
const pollOptions =
|
|
93
96
|
postData.data.type === 'question'
|
|
94
97
|
? postData.data.options.map((option) => option.content)
|
|
@@ -111,15 +114,21 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
111
114
|
return false;
|
|
112
115
|
}
|
|
113
116
|
if (postData.data.type === 'question') {
|
|
114
|
-
return
|
|
117
|
+
return canSubmitPostContent({
|
|
118
|
+
visibleContentLength,
|
|
119
|
+
attachmentsLength: postData.data.attachments?.length ?? 0,
|
|
120
|
+
composerType: 'question',
|
|
121
|
+
pollOptionsValid,
|
|
122
|
+
});
|
|
115
123
|
}
|
|
116
124
|
if (postData.type === 'article') {
|
|
117
125
|
return trimmedContent.length > 0;
|
|
118
126
|
}
|
|
119
|
-
return (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
return canSubmitPostContent({
|
|
128
|
+
visibleContentLength,
|
|
129
|
+
attachmentsLength: postData.data.attachments?.length ?? 0,
|
|
130
|
+
composerType: 'note',
|
|
131
|
+
});
|
|
123
132
|
}, [
|
|
124
133
|
attachmentsProcessing,
|
|
125
134
|
isPosting,
|
|
@@ -131,6 +140,7 @@ export const NewPost = ({ route, navigation }: PostProps) => {
|
|
|
131
140
|
postData.type,
|
|
132
141
|
postData.visibility,
|
|
133
142
|
trimmedContent.length,
|
|
143
|
+
visibleContentLength,
|
|
134
144
|
]);
|
|
135
145
|
|
|
136
146
|
const handlePostCreation = async () => {
|