@openpeepshq/rn-components 0.5.0 → 0.5.2
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 +2 -2
- package/src/assets/audio/click-notification.wav +0 -0
- package/src/components/conversations/ConversationMessageBubble.tsx +10 -6
- package/src/components/conversations/ConversationPreviewCard.tsx +69 -50
- package/src/components/conversations/DirectMessagesHeaderActions.tsx +0 -1
- package/src/components/conversations/MessageInThread.tsx +9 -3
- package/src/components/custom/date/updating-date.tsx +8 -1
- package/src/components/jams/JamCallParticipant.tsx +25 -1
- package/src/components/post/types/Note.tsx +4 -5
- package/src/pages/conversations/Index.tsx +81 -29
- package/src/pages/conversations/Show.tsx +24 -58
- package/src/theme/defaults.ts +5 -0
- package/src/theme/types.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpeepshq/rn-components",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"validator": "^13.15.23",
|
|
142
142
|
"zustand": "^5.0.3",
|
|
143
143
|
"@openpeepshq/common": "^0.2.0",
|
|
144
|
-
"@openpeepshq/react": "^0.5.
|
|
144
|
+
"@openpeepshq/react": "^0.5.1"
|
|
145
145
|
},
|
|
146
146
|
"devDependencies": {
|
|
147
147
|
"@babel/core": "^7.26.7",
|
|
Binary file
|
|
@@ -4,7 +4,6 @@ import type { PublicPost } from '@openpeepshq/common/types';
|
|
|
4
4
|
import { useCurrentProfile } from '@openpeepshq/react';
|
|
5
5
|
import { FeedPostContent } from '../post/FeedPostContent';
|
|
6
6
|
import { UnreadPostIndicator } from '../post/pieces/UnreadPostIndicator';
|
|
7
|
-
import { ThemedView } from '../ui/themed-view';
|
|
8
7
|
|
|
9
8
|
export interface ConversationMessageBubbleProps {
|
|
10
9
|
message: PublicPost;
|
|
@@ -20,18 +19,23 @@ export const ConversationMessageBubble = ({
|
|
|
20
19
|
|
|
21
20
|
return (
|
|
22
21
|
<View
|
|
23
|
-
className={`mt-
|
|
22
|
+
className={`mt-4 w-full flex-row items-center gap-2 ${
|
|
24
23
|
mine ? 'justify-end' : 'justify-start'
|
|
25
24
|
}`}
|
|
26
25
|
>
|
|
27
|
-
<
|
|
26
|
+
<View
|
|
28
27
|
className={`w-[80%] rounded-t-xl p-3 ${
|
|
29
|
-
mine ? 'rounded-bl-xl bg-primary/10' : 'rounded-br-xl bg-
|
|
28
|
+
mine ? 'rounded-bl-xl bg-primary/10' : 'rounded-br-xl bg-surface-2'
|
|
30
29
|
}`}
|
|
31
30
|
>
|
|
32
31
|
<FeedPostContent post={message} />
|
|
33
|
-
</
|
|
34
|
-
{!mine ?
|
|
32
|
+
</View>
|
|
33
|
+
{!mine ? (
|
|
34
|
+
<UnreadPostIndicator
|
|
35
|
+
show={unread}
|
|
36
|
+
className="relative inset-auto shrink-0 translate-y-0"
|
|
37
|
+
/>
|
|
38
|
+
) : null}
|
|
35
39
|
</View>
|
|
36
40
|
);
|
|
37
41
|
};
|
|
@@ -2,22 +2,29 @@ import { View, TouchableOpacity } from 'react-native';
|
|
|
2
2
|
import React, { useCallback, useRef, useState } from 'react';
|
|
3
3
|
import { UpdatingDate } from '../custom/date/updating-date';
|
|
4
4
|
import { OpenpeepsMarkdown } from '../markdown/OpenpeepsMarkdown';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
formatBadgeCount,
|
|
7
|
+
truncateText,
|
|
8
|
+
type PublicPost,
|
|
9
|
+
} from '@openpeepshq/common';
|
|
6
10
|
import { Text } from '../ui/text';
|
|
7
|
-
import { Button } from '../ui/button';
|
|
8
11
|
import { BottomSheetModal } from '@gorhom/bottom-sheet';
|
|
9
12
|
import {
|
|
10
13
|
DropdownMenu,
|
|
11
14
|
DropdownMenuContent,
|
|
12
15
|
DropdownMenuItem,
|
|
13
16
|
} from '../ui/dropdown-menu';
|
|
14
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
BellOffIcon,
|
|
19
|
+
FlagIcon,
|
|
20
|
+
Trash2Icon,
|
|
21
|
+
CalendarIcon,
|
|
22
|
+
} from '../icons/index';
|
|
15
23
|
import { useOpenpeeps } from '@openpeepshq/react';
|
|
16
|
-
|
|
17
|
-
import { ProfileImages, ProfileName } from '../profile/ProfilePieces';
|
|
18
|
-
import { truncateText } from '../../lib/utils';
|
|
19
|
-
import { ProfileSheet } from '../profile/index';
|
|
24
|
+
import { ProfileAvatar } from '../profile/Avatar';
|
|
20
25
|
import { ConversationParticipantsModal } from './ConversationParticipantsModal';
|
|
26
|
+
import { useTranslation } from 'react-i18next';
|
|
27
|
+
|
|
21
28
|
interface ConversationPreviewCardProps {
|
|
22
29
|
conversation: PublicPost[];
|
|
23
30
|
onPress: () => void;
|
|
@@ -31,7 +38,7 @@ export const ConversationPreviewCard = ({
|
|
|
31
38
|
onLongPress,
|
|
32
39
|
unreadCount = 0,
|
|
33
40
|
}: ConversationPreviewCardProps) => {
|
|
34
|
-
const
|
|
41
|
+
const { t } = useTranslation();
|
|
35
42
|
const deleteMessageModalRef = useRef<BottomSheetModal>(null);
|
|
36
43
|
const [participantsOpen, setParticipantsOpen] = useState(false);
|
|
37
44
|
const { currentProfile } = useOpenpeeps();
|
|
@@ -43,10 +50,15 @@ export const ConversationPreviewCard = ({
|
|
|
43
50
|
(p) => p.id !== currentProfile?.id
|
|
44
51
|
);
|
|
45
52
|
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
const otherNames = otherParticipants
|
|
54
|
+
.map((p) => p.displayName || `@${p.handle}`)
|
|
55
|
+
.join(', ');
|
|
56
|
+
const title = otherNames
|
|
57
|
+
? t('conversations.titleWithYou', {
|
|
58
|
+
defaultValue: '{{names}} and You',
|
|
59
|
+
names: otherNames,
|
|
60
|
+
})
|
|
61
|
+
: t('common.you', { defaultValue: 'You' });
|
|
50
62
|
|
|
51
63
|
const handleDeleteGroupModalPress = useCallback(() => {
|
|
52
64
|
deleteMessageModalRef.current?.present();
|
|
@@ -59,43 +71,60 @@ export const ConversationPreviewCard = ({
|
|
|
59
71
|
onLongPress={onLongPress}
|
|
60
72
|
className="w-full mb-3"
|
|
61
73
|
>
|
|
62
|
-
<View className="flex w-full flex-
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
: participants
|
|
78
|
-
}
|
|
79
|
-
/>
|
|
74
|
+
<View className="flex w-full flex-col gap-x-1 border-b p-3 text-left">
|
|
75
|
+
<View className="flex flex-row items-center gap-4">
|
|
76
|
+
<View className="flex -space-x-2">
|
|
77
|
+
{participants.slice(0, 3).map((p) => (
|
|
78
|
+
<ProfileAvatar
|
|
79
|
+
key={p.id}
|
|
80
|
+
profile={p}
|
|
81
|
+
className="size-10 border-0"
|
|
82
|
+
/>
|
|
83
|
+
))}
|
|
84
|
+
</View>
|
|
85
|
+
<View className="flex min-w-0 flex-1 flex-row items-center gap-2">
|
|
86
|
+
<Text className="truncate font-bold">
|
|
87
|
+
{truncateText(title, 20)}
|
|
88
|
+
</Text>
|
|
80
89
|
{unreadCount > 0 ? (
|
|
81
|
-
<View className="bg-destructive size-5 min-w-5 shrink-0 items-center justify-center rounded-full px-1
|
|
90
|
+
<View className="bg-destructive size-5 min-w-5 shrink-0 items-center justify-center rounded-full px-1">
|
|
82
91
|
<Text className="text-xs font-semibold text-destructive-foreground">
|
|
83
92
|
{formatBadgeCount(unreadCount)}
|
|
84
93
|
</Text>
|
|
85
94
|
</View>
|
|
86
95
|
) : null}
|
|
87
96
|
</View>
|
|
88
|
-
<View className="flex-row gap-1">
|
|
89
|
-
<Text className="">{lastMessage.profile.handle}</Text>
|
|
90
|
-
<UpdatingDate date={lastMessage.createdAt} />
|
|
91
|
-
</View>
|
|
92
97
|
</View>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
linkPreviewMode="none"
|
|
98
|
+
|
|
99
|
+
<UpdatingDate
|
|
100
|
+
date={lastMessage.createdAt}
|
|
101
|
+
className="text-muted-foreground"
|
|
98
102
|
/>
|
|
103
|
+
|
|
104
|
+
<View className="mt-2 flex flex-row items-start gap-x-2">
|
|
105
|
+
<View className="flex flex-row items-center">
|
|
106
|
+
<Text>~</Text>
|
|
107
|
+
{currentProfile?.id === lastMessage.profile.id ? (
|
|
108
|
+
<Text className="ml-1">Me</Text>
|
|
109
|
+
) : (
|
|
110
|
+
<Text className="ml-1">
|
|
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>
|
|
121
|
+
) : (
|
|
122
|
+
<OpenpeepsMarkdown
|
|
123
|
+
source={lastMessage.data?.content || ''}
|
|
124
|
+
linkPreviewMode="none"
|
|
125
|
+
/>
|
|
126
|
+
)}
|
|
127
|
+
</View>
|
|
99
128
|
</View>
|
|
100
129
|
</TouchableOpacity>
|
|
101
130
|
<DropdownMenuContent>
|
|
@@ -117,16 +146,6 @@ export const ConversationPreviewCard = ({
|
|
|
117
146
|
<Text className="text-destructive">Delete conversation</Text>
|
|
118
147
|
</DropdownMenuItem>
|
|
119
148
|
</DropdownMenuContent>
|
|
120
|
-
{participants.length === 2 && otherParticipants.length > 0 && (
|
|
121
|
-
<ProfileSheet
|
|
122
|
-
ref={profileSheetRef}
|
|
123
|
-
profile={otherParticipants}
|
|
124
|
-
onConnect={() => {
|
|
125
|
-
console.log('Connect pressed');
|
|
126
|
-
profileSheetRef.current?.dismiss();
|
|
127
|
-
}}
|
|
128
|
-
/>
|
|
129
|
-
)}
|
|
130
149
|
{participants.length > 2 && (
|
|
131
150
|
<ConversationParticipantsModal
|
|
132
151
|
open={participantsOpen}
|
|
@@ -28,7 +28,7 @@ const audienceDiff = (
|
|
|
28
28
|
const AvatarRow = ({ profiles }: { profiles: PublicProfile[] }) => (
|
|
29
29
|
<View className="flex-row -space-x-2">
|
|
30
30
|
{profiles.map((p) => (
|
|
31
|
-
<ProfileAvatar key={p.id} profile={p} className="size-10" />
|
|
31
|
+
<ProfileAvatar key={p.id} profile={p} className="size-10 border-0" />
|
|
32
32
|
))}
|
|
33
33
|
</View>
|
|
34
34
|
);
|
|
@@ -74,7 +74,10 @@ export const MessageInThread = ({
|
|
|
74
74
|
inAudience(previous, message.profile) &&
|
|
75
75
|
!inAudience(message, message.profile) ? (
|
|
76
76
|
<View className="flex-row items-center gap-2">
|
|
77
|
-
<ProfileAvatar
|
|
77
|
+
<ProfileAvatar
|
|
78
|
+
profile={message.profile}
|
|
79
|
+
className="size-10 border-0"
|
|
80
|
+
/>
|
|
78
81
|
<ThemedText>
|
|
79
82
|
{t('conversations.messageInThread.left', { name })}
|
|
80
83
|
</ThemedText>
|
|
@@ -102,7 +105,10 @@ export const MessageInThread = ({
|
|
|
102
105
|
<View ref={postViewRef} className="flex-row">
|
|
103
106
|
{!isMe && multipleParticipants ? (
|
|
104
107
|
<View className="mr-2 mt-6">
|
|
105
|
-
<ProfileAvatar
|
|
108
|
+
<ProfileAvatar
|
|
109
|
+
profile={message.profile}
|
|
110
|
+
className="size-10 border-0"
|
|
111
|
+
/>
|
|
106
112
|
</View>
|
|
107
113
|
) : null}
|
|
108
114
|
<View className="min-w-0 flex-1">
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { dateFormatter } from './formatter';
|
|
3
3
|
import { ThemedText } from '../../ui/themed-text';
|
|
4
|
+
import { cn } from '../../../lib/utils';
|
|
4
5
|
|
|
5
6
|
interface UpdatingDateProps {
|
|
6
7
|
date: string | Date | number;
|
|
7
8
|
formatter?: (date: string | Date | number) => string;
|
|
9
|
+
className?: string;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export const UpdatingDate = ({
|
|
11
13
|
date,
|
|
12
14
|
formatter = dateFormatter,
|
|
15
|
+
className,
|
|
13
16
|
}: UpdatingDateProps) => {
|
|
14
17
|
const [formattedDate, setFormattedDate] = React.useState(formatter(date));
|
|
15
18
|
|
|
@@ -20,5 +23,9 @@ export const UpdatingDate = ({
|
|
|
20
23
|
return () => clearInterval(interval);
|
|
21
24
|
}, [date, formatter]);
|
|
22
25
|
|
|
23
|
-
return
|
|
26
|
+
return (
|
|
27
|
+
<ThemedText className={cn('text-sm', className)}>
|
|
28
|
+
{formattedDate}
|
|
29
|
+
</ThemedText>
|
|
30
|
+
);
|
|
24
31
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import { Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
import Sound from 'react-native-sound';
|
|
3
4
|
import {
|
|
4
5
|
isTrackReference,
|
|
5
6
|
type TrackReferenceOrPlaceholder,
|
|
@@ -175,6 +176,7 @@ const JamParticipantOverlay = ({
|
|
|
175
176
|
|
|
176
177
|
const micOn = participant.isMicrophoneEnabled;
|
|
177
178
|
const handUp = raisedHands.has(participant.identity);
|
|
179
|
+
const handRaiseSound = useRef<Sound | null>(null);
|
|
178
180
|
const profile = parseParticipantMetadata(participant.metadata).profile;
|
|
179
181
|
const isModerator = jam.moderators.includes(participant.identity);
|
|
180
182
|
const viewerIsModerator = !!me && jam.moderators.includes(me.id);
|
|
@@ -182,6 +184,28 @@ const JamParticipantOverlay = ({
|
|
|
182
184
|
const micIconClass =
|
|
183
185
|
micOn && speaking && !connectionLost ? 'text-primary' : 'text-foreground';
|
|
184
186
|
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
const sound = new Sound(
|
|
189
|
+
require('../../assets/audio/click-notification.wav'),
|
|
190
|
+
(err) => {
|
|
191
|
+
if (!err) {
|
|
192
|
+
sound.setVolume(0.5);
|
|
193
|
+
handRaiseSound.current = sound;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
return () => {
|
|
198
|
+
sound.release();
|
|
199
|
+
handRaiseSound.current = null;
|
|
200
|
+
};
|
|
201
|
+
}, []);
|
|
202
|
+
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
if (handUp) {
|
|
205
|
+
handRaiseSound.current?.play();
|
|
206
|
+
}
|
|
207
|
+
}, [handUp]);
|
|
208
|
+
|
|
185
209
|
return (
|
|
186
210
|
<View
|
|
187
211
|
pointerEvents="box-none"
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { PublicPost } from '@openpeepshq/common/types';
|
|
3
|
-
|
|
4
|
-
import { Attachments } from '../pieces/Attachments';
|
|
5
|
-
|
|
6
2
|
import { View } from 'react-native';
|
|
3
|
+
import type { PublicPost } from '@openpeepshq/common/types';
|
|
7
4
|
import { ThemedText } from '../../ui/themed-text';
|
|
8
5
|
import { OpenpeepsMarkdown } from '../../markdown/index';
|
|
6
|
+
import { Attachments } from '../pieces/Attachments';
|
|
9
7
|
|
|
10
8
|
export interface FeedNoteProps {
|
|
11
9
|
post: PublicPost;
|
|
@@ -14,11 +12,12 @@ export interface FeedNoteProps {
|
|
|
14
12
|
export const FeedNote = ({ post }: FeedNoteProps) =>
|
|
15
13
|
post?.data?.type === 'note' ? (
|
|
16
14
|
<View>
|
|
17
|
-
<Attachments {...{ post }} />
|
|
18
15
|
<OpenpeepsMarkdown
|
|
19
16
|
source={post?.data?.content || ''}
|
|
17
|
+
mentions={post.mentions}
|
|
20
18
|
linkPreviewMode={post?.data?.attachments?.length ? 'none' : 'append'}
|
|
21
19
|
/>
|
|
20
|
+
<Attachments {...{ post }} />
|
|
22
21
|
</View>
|
|
23
22
|
) : (
|
|
24
23
|
<View>
|
|
@@ -4,8 +4,9 @@ import {
|
|
|
4
4
|
TouchableOpacity,
|
|
5
5
|
View,
|
|
6
6
|
} from 'react-native';
|
|
7
|
-
import React, { useEffect, useRef } from 'react';
|
|
8
|
-
import {
|
|
7
|
+
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
8
|
+
import { MessageCircleOffIcon } from '../../components/icons/index';
|
|
9
|
+
import { ThemedText } from '../../components/ui/themed-text';
|
|
9
10
|
import {
|
|
10
11
|
useSetPageHeader,
|
|
11
12
|
useSetPlusButtonActions,
|
|
@@ -23,20 +24,21 @@ import { canCreatePost, PublicPost } from '@openpeepshq/common';
|
|
|
23
24
|
import { Input } from '../../components/ui/input';
|
|
24
25
|
import { profileMatchesQuery } from '../../lib/utils';
|
|
25
26
|
import { BottomSheetModal } from '@gorhom/bottom-sheet';
|
|
26
|
-
|
|
27
27
|
import {
|
|
28
28
|
ConversationPreviewCard,
|
|
29
29
|
DirectMessagesHeaderActions,
|
|
30
30
|
useCreateNewConversation,
|
|
31
31
|
} from '../../components/conversations/index';
|
|
32
32
|
import { useTranslation } from 'react-i18next';
|
|
33
|
-
|
|
34
33
|
import { ConversationSettingsSheet } from '../../components/conversations/index';
|
|
34
|
+
|
|
35
35
|
type MessagesProps = CompositeScreenProps<
|
|
36
36
|
NativeStackScreenProps<TabStackParamList, 'Messages'>,
|
|
37
37
|
NativeStackScreenProps<MainStackParamList>
|
|
38
38
|
>;
|
|
39
39
|
|
|
40
|
+
type ConversationsTab = 'active' | 'archived';
|
|
41
|
+
|
|
40
42
|
export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
|
|
41
43
|
const { openpeepsApi } = useOpenpeeps();
|
|
42
44
|
const { t } = useTranslation();
|
|
@@ -44,40 +46,42 @@ export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
|
|
|
44
46
|
const canCreate = canCreatePost(authData, 'note', 'direct');
|
|
45
47
|
const { openCreateConversation } = useCreateNewConversation();
|
|
46
48
|
const settingsRef = useRef<BottomSheetModal>(null);
|
|
47
|
-
const [refreshing, setRefreshing] =
|
|
48
|
-
const [filteredConversations, setFilteredConversations] =
|
|
49
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
50
|
+
const [filteredConversations, setFilteredConversations] = useState<
|
|
49
51
|
PublicPost[][]
|
|
50
52
|
>([]);
|
|
51
|
-
const [searchQuery, setSearchQuery] =
|
|
52
|
-
const [isSearchToggled, setIsSearchToggled] =
|
|
53
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
54
|
+
const [isSearchToggled, setIsSearchToggled] = useState(false);
|
|
55
|
+
const [tab, setTab] = useState<ConversationsTab>('active');
|
|
53
56
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
isLoading,
|
|
57
|
-
refetch,
|
|
58
|
-
} = openpeepsApi.useConversations();
|
|
57
|
+
const query = openpeepsApi.useConversations();
|
|
58
|
+
const archivedQuery = openpeepsApi.useArchivedConversations();
|
|
59
59
|
const unseenCountsQuery = openpeepsApi.useUnseenPostCounts();
|
|
60
60
|
const unseenByConversation = unseenCountsQuery.data?.direct ?? {};
|
|
61
61
|
|
|
62
|
+
const activeQuery = tab === 'active' ? query : archivedQuery;
|
|
63
|
+
const conversations = useMemo(
|
|
64
|
+
() => activeQuery.data ?? [],
|
|
65
|
+
[activeQuery.data]
|
|
66
|
+
);
|
|
67
|
+
|
|
62
68
|
const onRefresh = React.useCallback(async () => {
|
|
63
69
|
setRefreshing(true);
|
|
64
|
-
refetch()
|
|
70
|
+
await activeQuery.refetch();
|
|
65
71
|
setRefreshing(false);
|
|
66
|
-
}, [
|
|
72
|
+
}, [activeQuery]);
|
|
67
73
|
|
|
68
74
|
useEffect(() => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
setFilteredConversations(filtered);
|
|
80
|
-
}
|
|
75
|
+
const filtered = conversations.filter((conversation) =>
|
|
76
|
+
conversation.some(
|
|
77
|
+
(message) =>
|
|
78
|
+
message?.data?.content
|
|
79
|
+
?.toLowerCase()
|
|
80
|
+
.includes(searchQuery.toLowerCase()) ||
|
|
81
|
+
profileMatchesQuery(message.profile, searchQuery)
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
setFilteredConversations(filtered);
|
|
81
85
|
}, [conversations, searchQuery]);
|
|
82
86
|
|
|
83
87
|
useSetPageHeader(
|
|
@@ -109,6 +113,44 @@ export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
|
|
|
109
113
|
<DirectMessagesHeaderActions />
|
|
110
114
|
</View>
|
|
111
115
|
);
|
|
116
|
+
|
|
117
|
+
const headerTabs = (
|
|
118
|
+
<View className="flex-row border-b border-border">
|
|
119
|
+
<TouchableOpacity
|
|
120
|
+
onPress={() => setTab('active')}
|
|
121
|
+
className={`px-4 py-2 text-sm ${
|
|
122
|
+
tab === 'active'
|
|
123
|
+
? 'border-primary border-b-2 font-semibold'
|
|
124
|
+
: 'text-muted-foreground'
|
|
125
|
+
}`}
|
|
126
|
+
>
|
|
127
|
+
<ThemedText
|
|
128
|
+
className={
|
|
129
|
+
tab === 'active' ? 'font-semibold' : 'text-muted-foreground'
|
|
130
|
+
}
|
|
131
|
+
>
|
|
132
|
+
{t('conversations.tabs.active', { defaultValue: 'Active' })}
|
|
133
|
+
</ThemedText>
|
|
134
|
+
</TouchableOpacity>
|
|
135
|
+
<TouchableOpacity
|
|
136
|
+
onPress={() => setTab('archived')}
|
|
137
|
+
className={`px-4 py-2 text-sm ${
|
|
138
|
+
tab === 'archived'
|
|
139
|
+
? 'border-primary border-b-2 font-semibold'
|
|
140
|
+
: 'text-muted-foreground'
|
|
141
|
+
}`}
|
|
142
|
+
>
|
|
143
|
+
<ThemedText
|
|
144
|
+
className={
|
|
145
|
+
tab === 'archived' ? 'font-semibold' : 'text-muted-foreground'
|
|
146
|
+
}
|
|
147
|
+
>
|
|
148
|
+
{t('conversations.tabs.archived', { defaultValue: 'Archived' })}
|
|
149
|
+
</ThemedText>
|
|
150
|
+
</TouchableOpacity>
|
|
151
|
+
</View>
|
|
152
|
+
);
|
|
153
|
+
|
|
112
154
|
useSetPlusButtonActions(
|
|
113
155
|
canCreate
|
|
114
156
|
? {
|
|
@@ -118,8 +160,11 @@ export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
|
|
|
118
160
|
: undefined
|
|
119
161
|
);
|
|
120
162
|
|
|
163
|
+
const isLoading = activeQuery.isLoading;
|
|
164
|
+
|
|
121
165
|
return (
|
|
122
|
-
<View className="
|
|
166
|
+
<View className="flex-1">
|
|
167
|
+
{headerTabs}
|
|
123
168
|
<KeyboardAwareScrollView
|
|
124
169
|
refreshControl={
|
|
125
170
|
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
|
|
@@ -129,7 +174,14 @@ export const ConversationsIndex: React.FC<MessagesProps> = ({ navigation }) => {
|
|
|
129
174
|
>
|
|
130
175
|
{isLoading && <ActivityIndicator size={'small'} />}
|
|
131
176
|
{!isLoading && filteredConversations?.length === 0 && (
|
|
132
|
-
<
|
|
177
|
+
<View className="flex h-[80vh] items-center justify-center gap-2">
|
|
178
|
+
<MessageCircleOffIcon size={40} className="text-muted-foreground" />
|
|
179
|
+
<ThemedText className="text-muted-foreground">
|
|
180
|
+
{t('conversations.empty', {
|
|
181
|
+
defaultValue: 'No direct messages here',
|
|
182
|
+
})}
|
|
183
|
+
</ThemedText>
|
|
184
|
+
</View>
|
|
133
185
|
)}
|
|
134
186
|
{!isLoading &&
|
|
135
187
|
filteredConversations?.map((conversation, idx) => (
|
|
@@ -16,24 +16,20 @@ import {
|
|
|
16
16
|
Platform,
|
|
17
17
|
ActivityIndicator,
|
|
18
18
|
} from 'react-native';
|
|
19
|
-
import { InfoIcon
|
|
19
|
+
import { InfoIcon } from '../../components/icons/index';
|
|
20
20
|
import { MediaAttachmentData } from '@openpeepshq/common';
|
|
21
21
|
import { ComposeAttachments } from '../../components/post/post-form/ComposeAttachments';
|
|
22
22
|
import { OpenpeepsMarkdownInput } from '../../components/post/post-form/OpenpeepsMarkdownInput';
|
|
23
23
|
import { maxContentLength } from '../../lib/utils';
|
|
24
24
|
import { DropdownMenu } from '../../components/ui/dropdown-menu';
|
|
25
|
+
import { Button } from '../../components/ui/button';
|
|
26
|
+
import { ThemedText } from '../../components/ui/themed-text';
|
|
25
27
|
import {
|
|
26
28
|
ConversationParticipantsModal,
|
|
27
29
|
ConversationProfileHeader,
|
|
28
30
|
MessageInThread,
|
|
29
31
|
} from '../../components/conversations/index';
|
|
30
32
|
|
|
31
|
-
import {
|
|
32
|
-
ProfileBio,
|
|
33
|
-
ProfileHandle,
|
|
34
|
-
ProfileImages,
|
|
35
|
-
ProfileName,
|
|
36
|
-
} from '../../components/profile/index';
|
|
37
33
|
type ConversationProps = MainScreenProps<'Conversation'>;
|
|
38
34
|
|
|
39
35
|
export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
@@ -106,6 +102,14 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
106
102
|
void markPostsSeen({ postIds: unseenIds });
|
|
107
103
|
}, [id, currentProfile, messages, isLoading, markPostsSeen]);
|
|
108
104
|
|
|
105
|
+
if (isLoading) {
|
|
106
|
+
return (
|
|
107
|
+
<ThemedView className="flex-1 items-center justify-center">
|
|
108
|
+
<ActivityIndicator size="large" />
|
|
109
|
+
</ThemedView>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
109
113
|
useSetPageHeader(
|
|
110
114
|
<ConversationProfileHeader
|
|
111
115
|
participants={headerParticipants}
|
|
@@ -114,7 +118,7 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
114
118
|
<TouchableOpacity
|
|
115
119
|
onPress={() => navigation.navigate('ConversationInfo', { id })}
|
|
116
120
|
>
|
|
117
|
-
<InfoIcon size={
|
|
121
|
+
<InfoIcon size={18} className="text-foreground" />
|
|
118
122
|
</TouchableOpacity>
|
|
119
123
|
);
|
|
120
124
|
|
|
@@ -134,41 +138,6 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
134
138
|
scrollViewRef.current?.scrollToEnd({ animated: true })
|
|
135
139
|
}
|
|
136
140
|
>
|
|
137
|
-
{messages?.[0]?.audience?.length === 2 && (
|
|
138
|
-
<View className="bg-background border-b border-border">
|
|
139
|
-
<View className="flex items-center justify-center py-6">
|
|
140
|
-
<ProfileImages
|
|
141
|
-
profile={
|
|
142
|
-
messages?.[0].audience.filter(
|
|
143
|
-
(p) => p.id !== currentProfile?.id
|
|
144
|
-
) || []
|
|
145
|
-
}
|
|
146
|
-
/>
|
|
147
|
-
<ProfileName
|
|
148
|
-
profile={
|
|
149
|
-
messages?.[0].audience.filter(
|
|
150
|
-
(p) => p.id !== currentProfile?.id
|
|
151
|
-
) || []
|
|
152
|
-
}
|
|
153
|
-
/>
|
|
154
|
-
<ProfileHandle
|
|
155
|
-
profile={
|
|
156
|
-
messages?.[0].audience.filter(
|
|
157
|
-
(p) => p.id !== currentProfile?.id
|
|
158
|
-
) || []
|
|
159
|
-
}
|
|
160
|
-
/>
|
|
161
|
-
<ProfileBio
|
|
162
|
-
profile={
|
|
163
|
-
messages?.[0].audience.filter(
|
|
164
|
-
(p) => p.id !== currentProfile?.id
|
|
165
|
-
) || []
|
|
166
|
-
}
|
|
167
|
-
/>
|
|
168
|
-
</View>
|
|
169
|
-
</View>
|
|
170
|
-
)}
|
|
171
|
-
|
|
172
141
|
{messages?.map((message, idx) => (
|
|
173
142
|
<View key={message.id} className="px-2">
|
|
174
143
|
<MessageInThread
|
|
@@ -206,31 +175,28 @@ export const ConversationShow = ({ route, navigation }: ConversationProps) => {
|
|
|
206
175
|
})}
|
|
207
176
|
/>
|
|
208
177
|
<View className="flex-row justify-end">
|
|
209
|
-
<
|
|
178
|
+
<Button
|
|
179
|
+
variant="default"
|
|
210
180
|
onPress={handleSendMessage}
|
|
211
181
|
disabled={
|
|
212
182
|
isSending ||
|
|
213
183
|
!content.trim() ||
|
|
214
184
|
content.length > maxContentLength
|
|
215
185
|
}
|
|
216
|
-
className={`p-2 rounded-full ${
|
|
217
|
-
content.trim() && content.length <= maxContentLength
|
|
218
|
-
? 'bg-primary'
|
|
219
|
-
: 'bg-surface'
|
|
220
|
-
}`}
|
|
221
186
|
>
|
|
222
187
|
{isSending ? (
|
|
223
|
-
<
|
|
188
|
+
<View className="flex-row items-center">
|
|
189
|
+
<ActivityIndicator size="small" />
|
|
190
|
+
<ThemedText className="ml-2">
|
|
191
|
+
{t('common.sending', { defaultValue: 'Sending…' })}
|
|
192
|
+
</ThemedText>
|
|
193
|
+
</View>
|
|
224
194
|
) : (
|
|
225
|
-
<
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
? 'text-primary-foreground'
|
|
229
|
-
: 'text-muted-foreground'
|
|
230
|
-
}
|
|
231
|
-
/>
|
|
195
|
+
<ThemedText>
|
|
196
|
+
{t('common.send', { defaultValue: 'Send' })}
|
|
197
|
+
</ThemedText>
|
|
232
198
|
)}
|
|
233
|
-
</
|
|
199
|
+
</Button>
|
|
234
200
|
</View>
|
|
235
201
|
</View>
|
|
236
202
|
</View>
|
package/src/theme/defaults.ts
CHANGED