@openpeepshq/rn-components 0.9.0 → 0.9.19
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/conversations/ConversationPreviewCard.tsx +37 -20
- package/src/components/conversations/MessageInThread.test.tsx +169 -0
- package/src/components/conversations/MessageInThread.tsx +51 -47
- package/src/pages/conversations/Show.tsx +6 -0
- package/src/pages/events/New.tsx +26 -6
- package/src/pages/posts/Reply.tsx +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.19",
|
|
4
4
|
"description": "React Native community screens and shared UI (extracted from the Black Ambition app) for the OpenPeeps stack.",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -142,8 +142,8 @@
|
|
|
142
142
|
"timezones-list": "^3.1.0",
|
|
143
143
|
"validator": "^13.15.23",
|
|
144
144
|
"zustand": "^5.0.3",
|
|
145
|
-
"@openpeepshq/common": "^0.5.
|
|
146
|
-
"@openpeepshq/react": "^0.9.
|
|
145
|
+
"@openpeepshq/common": "^0.5.12",
|
|
146
|
+
"@openpeepshq/react": "^0.9.22"
|
|
147
147
|
},
|
|
148
148
|
"devDependencies": {
|
|
149
149
|
"@babel/core": "^7.26.7",
|
|
@@ -4,6 +4,8 @@ import { UpdatingDate } from '../custom/date/updating-date';
|
|
|
4
4
|
import { OpenpeepsMarkdown } from '../markdown/OpenpeepsMarkdown';
|
|
5
5
|
import {
|
|
6
6
|
formatBadgeCount,
|
|
7
|
+
isConversationLeavePost,
|
|
8
|
+
profileName,
|
|
7
9
|
truncateText,
|
|
8
10
|
type PublicPost,
|
|
9
11
|
} from '@openpeepshq/common';
|
|
@@ -45,6 +47,9 @@ export const ConversationPreviewCard = ({
|
|
|
45
47
|
|
|
46
48
|
const lastMessage = conversation?.slice(-1)[0];
|
|
47
49
|
const participants = lastMessage?.audience || [];
|
|
50
|
+
// A leave post (isConversationLeavePost) leaves its author out of the
|
|
51
|
+
// audience; show an "X left" preview instead of an empty message.
|
|
52
|
+
const isLeave = lastMessage ? isConversationLeavePost(lastMessage) : false;
|
|
48
53
|
|
|
49
54
|
const otherParticipants = participants.filter(
|
|
50
55
|
(p) => p.id !== currentProfile?.id
|
|
@@ -102,27 +107,39 @@ export const ConversationPreviewCard = ({
|
|
|
102
107
|
/>
|
|
103
108
|
|
|
104
109
|
<View className="mt-2 flex flex-row items-start gap-x-2">
|
|
105
|
-
|
|
106
|
-
<Text
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
@{truncateText(lastMessage.profile.handle, 8)}
|
|
112
|
-
</Text>
|
|
113
|
-
)}
|
|
114
|
-
<Text className="mx-1">:</Text>
|
|
115
|
-
</View>
|
|
116
|
-
{lastMessage.data?.type === 'event' ? (
|
|
117
|
-
<View className="flex flex-row items-center gap-1">
|
|
118
|
-
<CalendarIcon size={16} className="text-muted-foreground" />
|
|
119
|
-
<Text>{(lastMessage.data as { name?: string }).name}</Text>
|
|
120
|
-
</View>
|
|
110
|
+
{isLeave ? (
|
|
111
|
+
<Text className="text-muted-foreground">
|
|
112
|
+
{t('conversations.messageInThread.left', {
|
|
113
|
+
name: profileName(lastMessage.profile),
|
|
114
|
+
})}
|
|
115
|
+
</Text>
|
|
121
116
|
) : (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
<>
|
|
118
|
+
<View className="flex flex-row items-center">
|
|
119
|
+
<Text>~</Text>
|
|
120
|
+
{currentProfile?.id === lastMessage.profile.id ? (
|
|
121
|
+
<Text className="ml-1">
|
|
122
|
+
{t('common.you', { defaultValue: 'You' })}
|
|
123
|
+
</Text>
|
|
124
|
+
) : (
|
|
125
|
+
<Text className="ml-1">
|
|
126
|
+
@{truncateText(lastMessage.profile.handle, 8)}
|
|
127
|
+
</Text>
|
|
128
|
+
)}
|
|
129
|
+
<Text className="mx-1">:</Text>
|
|
130
|
+
</View>
|
|
131
|
+
{lastMessage.data?.type === 'event' ? (
|
|
132
|
+
<View className="flex flex-row items-center gap-1">
|
|
133
|
+
<CalendarIcon size={16} className="text-muted-foreground" />
|
|
134
|
+
<Text>{(lastMessage.data as { name?: string }).name}</Text>
|
|
135
|
+
</View>
|
|
136
|
+
) : (
|
|
137
|
+
<OpenpeepsMarkdown
|
|
138
|
+
source={lastMessage.data?.content || ''}
|
|
139
|
+
linkPreviewMode="none"
|
|
140
|
+
/>
|
|
141
|
+
)}
|
|
142
|
+
</>
|
|
126
143
|
)}
|
|
127
144
|
</View>
|
|
128
145
|
</View>
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Leave rendering for MessageInThread: a leave (a reply that leaves its
|
|
3
|
+
* author out of the audience) renders only the "left" label, with the
|
|
4
|
+
* post-view ref wired to the label so the post still counts as seen.
|
|
5
|
+
*
|
|
6
|
+
* The View mock records the ref it is handed instead of asserting on
|
|
7
|
+
* ref.current: in this node jest environment (react 19.2.6 +
|
|
8
|
+
* react-test-renderer 19.2.3) host-element refs are never attached, even
|
|
9
|
+
* for plain host elements, while class refs work — an environment
|
|
10
|
+
* quirk, so the ref wiring is asserted directly.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const React = require('react');
|
|
14
|
+
const ReactTestRenderer = require('react-test-renderer');
|
|
15
|
+
|
|
16
|
+
const mockViewRefs: unknown[] = [];
|
|
17
|
+
|
|
18
|
+
jest.mock('react-native', () => ({
|
|
19
|
+
View: React.forwardRef((props: { children?: unknown }, ref: unknown) => {
|
|
20
|
+
if (ref) mockViewRefs.push(ref);
|
|
21
|
+
return React.createElement('View', null, props.children);
|
|
22
|
+
}),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
jest.mock('react-i18next', () => {
|
|
26
|
+
const translations: Record<string, string> = {
|
|
27
|
+
'conversations.messageInThread.startedBy': 'Started by {{name}}',
|
|
28
|
+
'conversations.messageInThread.addedBy': 'Added by {{name}}',
|
|
29
|
+
'conversations.messageInThread.left': '{{name}} left',
|
|
30
|
+
'conversations.messageInThread.removedBy': 'Removed by {{name}}',
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
useTranslation: () => ({
|
|
34
|
+
t: (key: string, opts?: Record<string, string>) =>
|
|
35
|
+
(translations[key] ?? key).replace(
|
|
36
|
+
/\{\{(\w+)\}\}/g,
|
|
37
|
+
(_match: string, name: string) => opts?.[name] ?? ''
|
|
38
|
+
),
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
jest.mock('@openpeepshq/common', () => {
|
|
44
|
+
// Mirrored from platform/common/src/lib/postHelpers.ts — the built
|
|
45
|
+
// package ships ESM which Jest's node transform doesn't cover.
|
|
46
|
+
const isConversationLeavePost = (post: {
|
|
47
|
+
inReplyToId?: string | null;
|
|
48
|
+
audience?: { id: string }[] | null;
|
|
49
|
+
profile: { id: string };
|
|
50
|
+
}): boolean => {
|
|
51
|
+
const authorId = post.profile?.id;
|
|
52
|
+
if (!post.inReplyToId || !authorId) return false;
|
|
53
|
+
return !post.audience?.some((p) => p.id === authorId);
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
profileName: (profile?: { displayName?: string; handle?: string }) =>
|
|
57
|
+
profile?.displayName || profile?.handle,
|
|
58
|
+
isConversationLeavePost,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
jest.mock('@openpeepshq/react', () => ({
|
|
63
|
+
useCurrentProfile: () => undefined,
|
|
64
|
+
isUnreadPostForViewer: () => false,
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
const mockPostViewRef = { current: null as unknown };
|
|
68
|
+
|
|
69
|
+
jest.mock('../../hooks/use-post-view-ref', () => ({
|
|
70
|
+
usePostViewRef: () => mockPostViewRef,
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
jest.mock('./ConversationMessageBubble', () => ({
|
|
74
|
+
ConversationMessageBubble: () =>
|
|
75
|
+
React.createElement('Text', { testID: 'message-bubble' }, 'message bubble'),
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
jest.mock('../profile/Avatar', () => ({
|
|
79
|
+
ProfileAvatar: () => null,
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
jest.mock('../custom/date/updating-date', () => ({
|
|
83
|
+
UpdatingDate: () => null,
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
jest.mock('../ui/themed-text', () => ({
|
|
87
|
+
ThemedText: ({ children }: { children?: unknown }) =>
|
|
88
|
+
React.createElement('Text', null, children),
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
import type { PublicPost } from '@openpeepshq/common/types';
|
|
92
|
+
import { MessageInThread } from './MessageInThread';
|
|
93
|
+
|
|
94
|
+
const bob = { id: 'bob', displayName: 'Bob', handle: 'bob' };
|
|
95
|
+
const alice = { id: 'alice', displayName: 'Alice', handle: 'alice' };
|
|
96
|
+
|
|
97
|
+
const makePost = (over: Partial<PublicPost> = {}): PublicPost =>
|
|
98
|
+
({
|
|
99
|
+
id: 'post-1',
|
|
100
|
+
profile: bob,
|
|
101
|
+
audience: [alice, bob],
|
|
102
|
+
createdAt: '2026-01-01T00:00:00.000Z',
|
|
103
|
+
data: { type: 'note', content: 'hello' },
|
|
104
|
+
...over,
|
|
105
|
+
}) as never;
|
|
106
|
+
|
|
107
|
+
const render = (element: React.ReactElement) => {
|
|
108
|
+
mockViewRefs.length = 0;
|
|
109
|
+
let tree!: ReactTestRenderer.ReactTestRenderer;
|
|
110
|
+
ReactTestRenderer.act(() => {
|
|
111
|
+
tree = ReactTestRenderer.create(element);
|
|
112
|
+
});
|
|
113
|
+
return tree;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
test('renders only the left label for a leave post and wires the view ref to it', () => {
|
|
117
|
+
const tree = render(
|
|
118
|
+
<MessageInThread
|
|
119
|
+
previous={makePost({ id: 'prev-1' })}
|
|
120
|
+
message={makePost({ inReplyToId: 'prev-1', audience: [alice] })}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
const json = JSON.stringify(tree.toJSON());
|
|
124
|
+
expect(json).toContain('Bob left');
|
|
125
|
+
expect(json).not.toContain('message bubble');
|
|
126
|
+
// The leave label is the only rendered View that carries the post-view
|
|
127
|
+
// ref, so the ref must have been wired to it.
|
|
128
|
+
expect(mockViewRefs).toEqual([mockPostViewRef]);
|
|
129
|
+
tree.unmount();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('renders a leave post as left even when it is the first loaded post', () => {
|
|
133
|
+
const tree = render(
|
|
134
|
+
<MessageInThread
|
|
135
|
+
previous={undefined}
|
|
136
|
+
message={makePost({ inReplyToId: 'prev-1', audience: [alice] })}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
const json = JSON.stringify(tree.toJSON());
|
|
140
|
+
expect(json).toContain('Bob left');
|
|
141
|
+
expect(json).not.toContain('Added by');
|
|
142
|
+
tree.unmount();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('renders a root post outside its own audience as a message, not a leave', () => {
|
|
146
|
+
const tree = render(
|
|
147
|
+
<MessageInThread
|
|
148
|
+
previous={undefined}
|
|
149
|
+
message={makePost({ audience: [alice] })}
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
const json = JSON.stringify(tree.toJSON());
|
|
153
|
+
expect(json).toContain('message bubble');
|
|
154
|
+
expect(json).not.toContain('left');
|
|
155
|
+
tree.unmount();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test('renders a reply the author takes part in as a message', () => {
|
|
159
|
+
const tree = render(
|
|
160
|
+
<MessageInThread
|
|
161
|
+
previous={makePost({ id: 'prev-1' })}
|
|
162
|
+
message={makePost({ inReplyToId: 'prev-1' })}
|
|
163
|
+
/>
|
|
164
|
+
);
|
|
165
|
+
const json = JSON.stringify(tree.toJSON());
|
|
166
|
+
expect(json).toContain('message bubble');
|
|
167
|
+
expect(json).not.toContain('Bob left');
|
|
168
|
+
tree.unmount();
|
|
169
|
+
});
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import type { PublicPost, PublicProfile } from '@openpeepshq/common/types';
|
|
5
|
-
import { profileName } from '@openpeepshq/common';
|
|
5
|
+
import { isConversationLeavePost, profileName } from '@openpeepshq/common';
|
|
6
6
|
import { isUnreadPostForViewer, useCurrentProfile } from '@openpeepshq/react';
|
|
7
7
|
import { UpdatingDate } from '../custom/date/updating-date';
|
|
8
8
|
import { ProfileAvatar } from '../profile/Avatar';
|
|
@@ -10,9 +10,6 @@ import { ThemedText } from '../ui/themed-text';
|
|
|
10
10
|
import { usePostViewRef } from '../../hooks/use-post-view-ref';
|
|
11
11
|
import { ConversationMessageBubble } from './ConversationMessageBubble';
|
|
12
12
|
|
|
13
|
-
const inAudience = (post: PublicPost, profile: PublicProfile) =>
|
|
14
|
-
!!post.audience?.some((p) => p.id === profile.id);
|
|
15
|
-
|
|
16
13
|
const audienceDiff = (
|
|
17
14
|
previous: PublicPost | undefined,
|
|
18
15
|
message: PublicPost
|
|
@@ -59,12 +56,17 @@ export const MessageInThread = ({
|
|
|
59
56
|
// The author leaving their own conversation is shown via the "left" label
|
|
60
57
|
// below, so exclude them from the "removedBy" avatars to avoid redundancy.
|
|
61
58
|
const removedOthers = removed.filter((p) => p.id !== message.profile.id);
|
|
59
|
+
// A leave post (isConversationLeavePost) renders only the "left" label
|
|
60
|
+
// (no message bubble); the view-ref moves to that label so the post is
|
|
61
|
+
// still marked seen. It holds even when the leave is the first loaded
|
|
62
|
+
// post, so no comparison against the previous post is needed.
|
|
63
|
+
const isLeave = isConversationLeavePost(message);
|
|
62
64
|
const name = profileName(message.profile);
|
|
63
65
|
const isMe = message.profile.id === me?.id;
|
|
64
66
|
|
|
65
67
|
return (
|
|
66
68
|
<View className={highlighted ? 'bg-muted rounded-md' : undefined}>
|
|
67
|
-
{!previous ? (
|
|
69
|
+
{!previous && !isLeave ? (
|
|
68
70
|
<ThemedText className="mt-2 w-full text-center text-sm">
|
|
69
71
|
{message.inReplyToId
|
|
70
72
|
? t('conversations.messageInThread.addedBy', { name })
|
|
@@ -72,10 +74,8 @@ export const MessageInThread = ({
|
|
|
72
74
|
</ThemedText>
|
|
73
75
|
) : null}
|
|
74
76
|
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
!inAudience(message, message.profile) ? (
|
|
78
|
-
<View className="flex-row items-center gap-2">
|
|
77
|
+
{isLeave ? (
|
|
78
|
+
<View ref={postViewRef} className="flex-row items-center gap-2">
|
|
79
79
|
<ProfileAvatar
|
|
80
80
|
profile={message.profile}
|
|
81
81
|
className="size-10 border-0"
|
|
@@ -86,48 +86,52 @@ export const MessageInThread = ({
|
|
|
86
86
|
</View>
|
|
87
87
|
) : null}
|
|
88
88
|
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
{!isLeave ? (
|
|
90
|
+
<>
|
|
91
|
+
{previous && added.length > 0 ? (
|
|
92
|
+
<View className="flex-row items-center gap-2">
|
|
93
|
+
<AvatarRow profiles={added} />
|
|
94
|
+
<ThemedText>
|
|
95
|
+
{t('conversations.messageInThread.addedBy', { name })}
|
|
96
|
+
</ThemedText>
|
|
97
|
+
</View>
|
|
98
|
+
) : null}
|
|
97
99
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
{removedOthers.length > 0 ? (
|
|
101
|
+
<View className="flex-row items-center gap-2">
|
|
102
|
+
<AvatarRow profiles={removedOthers} />
|
|
103
|
+
<ThemedText>
|
|
104
|
+
{t('conversations.messageInThread.removedBy', { name })}
|
|
105
|
+
</ThemedText>
|
|
106
|
+
</View>
|
|
107
|
+
) : null}
|
|
106
108
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
109
|
+
<View ref={postViewRef} className="flex-row">
|
|
110
|
+
{!isMe && multipleParticipants ? (
|
|
111
|
+
<View className="mr-2 mt-6">
|
|
112
|
+
<ProfileAvatar
|
|
113
|
+
profile={message.profile}
|
|
114
|
+
className="size-10 border-0"
|
|
115
|
+
/>
|
|
116
|
+
</View>
|
|
117
|
+
) : null}
|
|
118
|
+
<View className="min-w-0 flex-1">
|
|
119
|
+
<ConversationMessageBubble message={message} unread={isUnread} />
|
|
120
|
+
</View>
|
|
114
121
|
</View>
|
|
115
|
-
) : null}
|
|
116
|
-
<View className="min-w-0 flex-1">
|
|
117
|
-
<ConversationMessageBubble message={message} unread={isUnread} />
|
|
118
|
-
</View>
|
|
119
|
-
</View>
|
|
120
122
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
123
|
+
<View
|
|
124
|
+
className={`mt-2 w-full flex-row text-sm ${
|
|
125
|
+
isMe ? 'justify-end' : 'justify-start'
|
|
126
|
+
}`}
|
|
127
|
+
>
|
|
128
|
+
{multipleParticipants && !isMe ? (
|
|
129
|
+
<ThemedText className="text-sm">{name} · </ThemedText>
|
|
130
|
+
) : null}
|
|
131
|
+
<UpdatingDate date={message.createdAt} />
|
|
132
|
+
</View>
|
|
133
|
+
</>
|
|
134
|
+
) : null}
|
|
131
135
|
</View>
|
|
132
136
|
);
|
|
133
137
|
};
|
|
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
2
2
|
import { MainScreenProps } from '../../components/navigation/types/index';
|
|
3
3
|
import {
|
|
4
4
|
adjustUnseenCounts,
|
|
5
|
+
apiErrorMessage,
|
|
5
6
|
useOpenpeeps,
|
|
6
7
|
usePostViewFlush,
|
|
7
8
|
} from '@openpeepshq/react';
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
Platform,
|
|
17
18
|
ActivityIndicator,
|
|
18
19
|
} from 'react-native';
|
|
20
|
+
import Toast from 'react-native-toast-message';
|
|
19
21
|
import { InfoIcon, SearchIcon } from '../../components/icons/index';
|
|
20
22
|
import { MediaAttachmentData, type PublicPost } from '@openpeepshq/common';
|
|
21
23
|
import { ComposeAttachments } from '../../components/post/post-form/ComposeAttachments';
|
|
@@ -133,6 +135,10 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
133
135
|
scrollViewRef.current?.scrollToEnd({ animated: true });
|
|
134
136
|
} catch (error) {
|
|
135
137
|
console.error('Failed to send message:', error);
|
|
138
|
+
Toast.show({
|
|
139
|
+
type: 'error',
|
|
140
|
+
text1: apiErrorMessage(error, t, t('conversations.sendError')),
|
|
141
|
+
});
|
|
136
142
|
} finally {
|
|
137
143
|
setIsSending(false);
|
|
138
144
|
}
|
package/src/pages/events/New.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import Toast from 'react-native-toast-message';
|
|
|
5
5
|
import { useNewEvent } from '@openpeepshq/react';
|
|
6
6
|
import { HeaderActionButton, useSetPageHeader } from '../../components/layout';
|
|
7
7
|
import { ThemedView } from '../../components/ui/themed-view';
|
|
8
|
+
import { ThemedText } from '../../components/ui/themed-text';
|
|
8
9
|
import { MainScreenProps } from '../../components/navigation/types/index';
|
|
9
10
|
import { EventForm } from '../../components/post/index';
|
|
10
11
|
|
|
@@ -15,6 +16,7 @@ export const NewEvent = (_props: NewEventProps) => {
|
|
|
15
16
|
const {
|
|
16
17
|
postData,
|
|
17
18
|
setPostData,
|
|
19
|
+
canCreate,
|
|
18
20
|
canSubmit,
|
|
19
21
|
submitting,
|
|
20
22
|
error,
|
|
@@ -33,14 +35,32 @@ export const NewEvent = (_props: NewEventProps) => {
|
|
|
33
35
|
|
|
34
36
|
useSetPageHeader(
|
|
35
37
|
t('events.create.title'),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
canCreate ? (
|
|
39
|
+
<HeaderActionButton
|
|
40
|
+
title={submitting ? t('common.submitting') : t('events.create.title')}
|
|
41
|
+
onPress={() => void submit()}
|
|
42
|
+
disabled={submitting || !canSubmit}
|
|
43
|
+
loading={submitting}
|
|
44
|
+
/>
|
|
45
|
+
) : undefined
|
|
42
46
|
);
|
|
43
47
|
|
|
48
|
+
if (!canCreate) {
|
|
49
|
+
return (
|
|
50
|
+
<ThemedView
|
|
51
|
+
className="flex-1 items-center justify-center gap-2 px-6 py-16"
|
|
52
|
+
testID="events-create-not-allowed"
|
|
53
|
+
>
|
|
54
|
+
<ThemedText className="text-center text-xl font-semibold">
|
|
55
|
+
{t('events.create.notAllowed.title')}
|
|
56
|
+
</ThemedText>
|
|
57
|
+
<ThemedText className="text-muted-foreground text-center text-sm">
|
|
58
|
+
{t('events.create.notAllowed.description')}
|
|
59
|
+
</ThemedText>
|
|
60
|
+
</ThemedView>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
44
64
|
return (
|
|
45
65
|
<ThemedView className="flex-1">
|
|
46
66
|
<KeyboardAwareScrollView
|
|
@@ -5,7 +5,7 @@ import React, {
|
|
|
5
5
|
useRef,
|
|
6
6
|
useState,
|
|
7
7
|
} from 'react';
|
|
8
|
-
import { useOpenpeeps } from '@openpeepshq/react';
|
|
8
|
+
import { apiErrorMessage, useOpenpeeps } from '@openpeepshq/react';
|
|
9
9
|
import {
|
|
10
10
|
AudioPickerSheet,
|
|
11
11
|
DocumentPickerSheet,
|
|
@@ -165,8 +165,11 @@ export const ReplyPost = ({ route, navigation }: PostProps) => {
|
|
|
165
165
|
await createPost(postData as PostCreationData);
|
|
166
166
|
|
|
167
167
|
handlePostSuccess();
|
|
168
|
-
} catch {
|
|
169
|
-
Toast.show({
|
|
168
|
+
} catch (err) {
|
|
169
|
+
Toast.show({
|
|
170
|
+
type: 'error',
|
|
171
|
+
text1: apiErrorMessage(err, t, t('posts.replyModal.errorToast')),
|
|
172
|
+
});
|
|
170
173
|
} finally {
|
|
171
174
|
setIsPosting(false);
|
|
172
175
|
}
|