@openpeepshq/react 0.8.6 → 0.9.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.
Files changed (36) hide show
  1. package/dist/components/conversations/DirectMessageSearch.d.ts +7 -0
  2. package/dist/components/conversations/DirectMessageSearch.js +46 -0
  3. package/dist/components/conversations/MessageInThread.d.ts +2 -1
  4. package/dist/components/conversations/MessageInThread.js +3 -3
  5. package/dist/components/conversations/index.d.ts +1 -0
  6. package/dist/components/conversations/index.js +1 -0
  7. package/dist/components/post/post-form/ReplyModal.js +5 -4
  8. package/dist/contexts/openpeeps/hooks/conversations.d.ts +3 -2
  9. package/dist/contexts/openpeeps/hooks/conversations.js +8 -1
  10. package/dist/hooks/events/useEventComposer.d.ts +1 -0
  11. package/dist/hooks/events/useEventComposer.js +8 -4
  12. package/dist/pages/admin/ConfigurationCommunity.js +1 -1
  13. package/dist/pages/admin/community/CommunityAccess.d.ts +6 -0
  14. package/dist/pages/admin/community/CommunityAccess.js +60 -0
  15. package/dist/pages/conversations/Index.js +17 -11
  16. package/dist/pages/conversations/Show.js +67 -15
  17. package/dist/pages/events/New.js +15 -4
  18. package/dist/pages/events/New.test.d.ts +1 -0
  19. package/dist/pages/events/New.test.js +69 -0
  20. package/dist/pages/index.d.ts +1 -0
  21. package/dist/pages/index.js +1 -0
  22. package/dist/pages/resources/Index.js +2 -2
  23. package/package.json +5 -5
  24. package/src/components/conversations/DirectMessageSearch.tsx +130 -0
  25. package/src/components/conversations/MessageInThread.tsx +9 -2
  26. package/src/components/conversations/index.ts +1 -0
  27. package/src/components/post/post-form/ReplyModal.tsx +9 -4
  28. package/src/contexts/openpeeps/hooks/conversations.ts +16 -3
  29. package/src/hooks/events/useEventComposer.ts +12 -3
  30. package/src/pages/admin/ConfigurationCommunity.tsx +4 -0
  31. package/src/pages/admin/community/CommunityAccess.tsx +129 -0
  32. package/src/pages/conversations/Index.tsx +51 -32
  33. package/src/pages/conversations/Show.tsx +106 -22
  34. package/src/pages/events/New.tsx +28 -5
  35. package/src/pages/index.ts +1 -0
  36. package/src/pages/resources/Index.tsx +2 -2
@@ -76,6 +76,7 @@ export { ConfigurationPluginPage } from './admin/ConfigurationPluginPage.js';
76
76
  export { AdminConfigurationCommunity } from './admin/ConfigurationCommunity.js';
77
77
  export { AdminConfigEditor } from './admin/ConfigEditor.js';
78
78
  export { AdminConfigurationI18n } from './admin/ConfigurationI18n.js';
79
+ export { AdminConfigurationCommunityAccess } from './admin/community/CommunityAccess.js';
79
80
  export { AdminConfigurationCommunityInfo } from './admin/community/CommunityInfo.js';
80
81
  export { AdminConfigurationCommunityLinks } from './admin/community/CommunityLinks.js';
81
82
  export { CommunityMarkdownPage } from './admin/community/CommunityMarkdownPage.js';
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback, useMemo } from 'react';
3
3
  import { FilePlus } from 'lucide-react';
4
- import { canCreatePostType } from '@openpeepshq/common/lib';
4
+ import { canCreatePostTypeIgnoringScopes } from '@openpeepshq/common/lib';
5
5
  import { useT, useSetPageHeader, useSetPlusButtonActions, useAuthData, } from '../../index.js';
6
6
  import { useNavigate } from '../../contexts/router/index.js';
7
7
  import { ResourceLibrary } from '../../components/resources/ResourceLibrary.js';
@@ -10,7 +10,7 @@ export const ResourcesIndex = () => {
10
10
  const t = useT();
11
11
  const navigate = useNavigate();
12
12
  const authData = useAuthData();
13
- const canCreate = canCreatePostType(authData, 'resource');
13
+ const canCreate = canCreatePostTypeIgnoringScopes(authData, 'resource');
14
14
  const openNew = useCallback(() => {
15
15
  const stores = getNewPostStores();
16
16
  stores.resource = { ...stores.resource, groupId: undefined };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/react",
3
- "version": "0.8.6",
3
+ "version": "0.9.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "@livekit/components-styles": "^1.1.6",
35
35
  "@tanstack/react-query": "5.90.16",
36
36
  "@videojs/react": "^10.0.0-beta.24",
37
- "dompurify": "^3.4.15",
37
+ "dompurify": "^3.4.17",
38
38
  "emoji-picker-element": "^1.29.1",
39
39
  "heic2any": "^0.0.4",
40
40
  "i18next": "^24.2.3",
@@ -51,10 +51,10 @@
51
51
  "react-i18next": "^15.4.1",
52
52
  "simple-icons": "^16.31.0",
53
53
  "uuidv7": "^1.0.2",
54
- "@openpeepshq/client": "^0.2.1",
55
- "@openpeepshq/common": "^0.4.0",
54
+ "@openpeepshq/client": "^0.3.0",
56
55
  "@openpeepshq/greenscreen": "^0.2.1",
57
- "@openpeepshq/react-ui": "^0.4.1"
56
+ "@openpeepshq/react-ui": "^0.4.1",
57
+ "@openpeepshq/common": "^0.5.0"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^18.3.0 || ^19.0.0",
@@ -0,0 +1,130 @@
1
+ import { useEffect, useState } from 'react';
2
+ import {
3
+ conversationLabel,
4
+ messagePreviewText,
5
+ profileName,
6
+ type DirectMessageSearchHit,
7
+ } from '@openpeepshq/common';
8
+ import { Input, UpdatingDate } from '@openpeepshq/react-ui';
9
+ import { useOpenpeeps } from '../../contexts/openpeeps';
10
+ import { useT } from '../../i18n';
11
+ import { useCurrentProfile } from '../layout/IdentityContext';
12
+
13
+ export const DirectMessageSearch = ({
14
+ conversationId,
15
+ autoFocus,
16
+ onQueryChange,
17
+ onSelect,
18
+ }: {
19
+ conversationId?: string;
20
+ autoFocus?: boolean;
21
+ onQueryChange?: (query: string) => void;
22
+ onSelect: (hit: DirectMessageSearchHit) => void;
23
+ }) => {
24
+ const t = useT();
25
+ const me = useCurrentProfile();
26
+ const { openpeepsApi } = useOpenpeeps();
27
+ const [input, setInput] = useState('');
28
+ const [query, setQuery] = useState('');
29
+
30
+ useEffect(() => {
31
+ const handle = setTimeout(() => setQuery(input.trim()), 300);
32
+ return () => clearTimeout(handle);
33
+ }, [input]);
34
+
35
+ useEffect(() => {
36
+ onQueryChange?.(query);
37
+ }, [query, onQueryChange]);
38
+
39
+ const search = openpeepsApi.useSearchDirectMessages(query, conversationId);
40
+ const active = query.length >= 2;
41
+ const hits = search.data ?? [];
42
+ const placeholder = conversationId
43
+ ? t('conversations.search.inConversation', {
44
+ defaultValue: 'Search this conversation…',
45
+ })
46
+ : t('conversations.search.placeholder', {
47
+ defaultValue: 'Search all messages…',
48
+ });
49
+
50
+ return (
51
+ <form
52
+ role="search"
53
+ className="border-border space-y-2 border-b p-3"
54
+ onSubmit={(event) => event.preventDefault()}
55
+ >
56
+ <Input
57
+ type="search"
58
+ value={input}
59
+ onChange={(event) => setInput(event.target.value)}
60
+ placeholder={placeholder}
61
+ aria-label={placeholder}
62
+ autoFocus={autoFocus}
63
+ data-testid="dm-search-input"
64
+ />
65
+ {active && search.isFetching ? (
66
+ <p className="text-muted-foreground text-sm">
67
+ {t('conversations.search.searching', { defaultValue: 'Searching…' })}
68
+ </p>
69
+ ) : null}
70
+ {active && search.isError ? (
71
+ <p className="text-destructive text-sm">
72
+ {t('conversations.search.error', { defaultValue: 'Search failed' })}
73
+ </p>
74
+ ) : null}
75
+ {active && !search.isFetching && !search.isError && hits.length === 0 ? (
76
+ <p className="text-muted-foreground text-sm">
77
+ {t('conversations.search.empty', {
78
+ defaultValue: 'No messages match "{{query}}"',
79
+ query,
80
+ })}
81
+ </p>
82
+ ) : null}
83
+ {active && hits.length > 0 ? (
84
+ <ul
85
+ aria-label={t('conversations.search.results', {
86
+ defaultValue: 'Message search results',
87
+ })}
88
+ className="max-h-64 overflow-y-auto"
89
+ data-testid="dm-search-results"
90
+ >
91
+ {hits.map((hit) => {
92
+ const senderId = hit.message.profile.id;
93
+ const sender =
94
+ senderId === me?.id
95
+ ? t('common.you', { defaultValue: 'You' })
96
+ : profileName(hit.message.profile);
97
+ const others = conversationLabel(hit.message, me?.id);
98
+ return (
99
+ <li key={hit.message.id}>
100
+ <button
101
+ type="button"
102
+ className="hover:bg-surface w-full rounded-md px-2 py-2 text-left"
103
+ title={t('conversations.search.openResult', {
104
+ defaultValue: 'Show this message',
105
+ })}
106
+ data-testid="dm-search-result"
107
+ onClick={() => onSelect(hit)}
108
+ >
109
+ {!conversationId && others ? (
110
+ <span className="block truncate text-sm font-semibold">
111
+ {others}
112
+ </span>
113
+ ) : null}
114
+ <span className="text-muted-foreground block truncate text-sm">
115
+ {sender}
116
+ {' · '}
117
+ <UpdatingDate date={hit.message.createdAt} />
118
+ </span>
119
+ <span className="line-clamp-2 text-sm">
120
+ {messagePreviewText(hit.message)}
121
+ </span>
122
+ </button>
123
+ </li>
124
+ );
125
+ })}
126
+ </ul>
127
+ ) : null}
128
+ </form>
129
+ );
130
+ };
@@ -28,6 +28,7 @@ export interface MessageInThreadProps {
28
28
  message: PublicPost;
29
29
  multipleParticipants?: boolean;
30
30
  conversationRootId?: string;
31
+ highlighted?: boolean;
31
32
  }
32
33
 
33
34
  /**
@@ -40,6 +41,7 @@ export function MessageInThread({
40
41
  message,
41
42
  multipleParticipants = true,
42
43
  conversationRootId,
44
+ highlighted = false,
43
45
  }: MessageInThreadProps) {
44
46
  const t = useT();
45
47
  const me = useCurrentProfile();
@@ -56,7 +58,12 @@ export function MessageInThread({
56
58
  const isMe = message.profile.id === me?.id;
57
59
 
58
60
  return (
59
- <>
61
+ <div
62
+ data-message-id={message.id}
63
+ className={
64
+ highlighted ? 'bg-muted ring-ring rounded-md ring-2' : undefined
65
+ }
66
+ >
60
67
  {!previous && (
61
68
  <div className="mt-2 w-full text-center text-sm">
62
69
  {message.inReplyToId
@@ -117,6 +124,6 @@ export function MessageInThread({
117
124
  {multipleParticipants && !isMe && <span>{name} &middot; </span>}
118
125
  <UpdatingDate date={message.createdAt} />
119
126
  </div>
120
- </>
127
+ </div>
121
128
  );
122
129
  }
@@ -5,6 +5,7 @@ export {
5
5
  useCreateNewConversation,
6
6
  } from './CreateNewConversationContext';
7
7
  export type { CreateConversationOptions } from './CreateNewConversationContext';
8
+ export { DirectMessageSearch } from './DirectMessageSearch';
8
9
  export { DirectMessagesHeaderActions } from './DirectMessagesHeaderActions';
9
10
  export { ConversationParticipantsModal } from './ConversationParticipantsModal';
10
11
  export type { ConversationParticipantsModalProps } from './ConversationParticipantsModal';
@@ -15,6 +15,7 @@ import {
15
15
  } from '@openpeepshq/react-ui';
16
16
  import { useOpenpeeps } from '../../../contexts/openpeeps';
17
17
  import { useT } from '../../../i18n';
18
+ import { apiErrorMessage } from '../../../lib/apiErrorMessage';
18
19
  import { useToast } from '../../layout/ToastProvider';
19
20
  import { useCurrentProfile } from '../../layout/IdentityContext';
20
21
  import {
@@ -179,11 +180,15 @@ export function ReplyModal({ post, onClose }: ReplyModalProps) {
179
180
  }),
180
181
  );
181
182
  onClose();
182
- } catch {
183
+ } catch (err) {
183
184
  toastError(
184
- t('posts.replyModal.errorToast', {
185
- defaultValue: 'Failed to post reply',
186
- }),
185
+ apiErrorMessage(
186
+ err,
187
+ t,
188
+ t('posts.replyModal.errorToast', {
189
+ defaultValue: 'An error occurred while creating the reply',
190
+ }),
191
+ ),
187
192
  );
188
193
  } finally {
189
194
  setSubmitting(false);
@@ -1,5 +1,6 @@
1
1
  import type { OpenpeepsClient } from '@openpeepshq/client';
2
2
  import type {
3
+ DirectMessageSearchHit,
3
4
  PostCreationData,
4
5
  PublicPost,
5
6
  SuccessFailureResponse,
@@ -13,7 +14,11 @@ type Query<T> = UseQueryResult<T, SuccessFailureResponse>;
13
14
  export type ConversationHooks = {
14
15
  useConversations: () => Query<PublicPost[][]>;
15
16
  useArchivedConversations: () => Query<PublicPost[][]>;
16
- useConversation: (id: string) => Query<PublicPost[]>;
17
+ useConversation: (id: string, messageId?: string) => Query<PublicPost[]>;
18
+ useSearchDirectMessages: (
19
+ q: string,
20
+ conversationId?: string,
21
+ ) => Query<DirectMessageSearchHit[]>;
17
22
  createConversationPostAction: (defaultPathParams?: {
18
23
  id: string;
19
24
  }) => (input: PostCreationData) => Promise<PublicPost>;
@@ -30,8 +35,16 @@ export const conversationHooks = (
30
35
  client.conversations.archived
31
36
  ? apiHook(client.conversations.archived)
32
37
  : ({ data: [], isPending: false } as never),
33
- useConversation: (id: string) =>
34
- apiHook(client.conversations.findById, { pathParams: { id } }),
38
+ useConversation: (id: string, messageId?: string) =>
39
+ apiHook(client.conversations.findById, {
40
+ pathParams: { id },
41
+ queryParams: messageId ? { message: messageId } : undefined,
42
+ }),
43
+ useSearchDirectMessages: (q: string, conversationId?: string) =>
44
+ apiHook(client.conversations.search, {
45
+ queryParams: conversationId ? { q, conversationId } : { q },
46
+ enabled: q.trim().length >= 2,
47
+ }),
35
48
  createConversationPostAction: payloadMutation(client.conversations.newPost, [
36
49
  ['conversations'],
37
50
  ]),
@@ -9,6 +9,7 @@ import type {
9
9
  PostDataUnion,
10
10
  } from '@openpeepshq/common/types';
11
11
  import {
12
+ canCreatePostTypeIgnoringScopes,
12
13
  effectiveEventTimes,
13
14
  normalizeEventDataForSave,
14
15
  upsertEventException,
@@ -16,15 +17,22 @@ import {
16
17
  import { useOpenpeeps } from '../../contexts/openpeeps';
17
18
  import { useNavigate } from '../../contexts/router';
18
19
  import { useT } from '../../i18n/context';
19
- import { useCurrentProfile } from '../../components/layout/IdentityContext';
20
+ import { useAuthData } from '../../components/layout/IdentityContext';
20
21
  import { useServerInfo } from '../../components/server-data/context';
21
22
  import { eventSanitizer, getNewPostStores } from '../../stores/newPosts';
23
+ import { AUDIENCE_CHOICE_VALUES } from '../../lib/audienceChoices';
22
24
 
23
25
  export const useNewEvent = () => {
24
26
  const t = useT();
25
27
  const navigate = useNavigate();
26
28
  const serverInfo = useServerInfo();
27
- const me = useCurrentProfile();
29
+ const authData = useAuthData();
30
+ // The form only offers these audiences; other visibilities would dead-end.
31
+ const canCreate = canCreatePostTypeIgnoringScopes(
32
+ authData,
33
+ 'event',
34
+ AUDIENCE_CHOICE_VALUES,
35
+ );
28
36
  const { openpeepsApi } = useOpenpeeps();
29
37
  const createPost = openpeepsApi.createPostAction();
30
38
  const announcePost = openpeepsApi.admin.announcePostAction();
@@ -42,7 +50,7 @@ export const useNewEvent = () => {
42
50
  const [error, setError] = useState<string | null>(null);
43
51
 
44
52
  const showNotify =
45
- canAnnouncePosts(me?.roles) &&
53
+ canAnnouncePosts(authData.profile?.roles) &&
46
54
  isCommunityWideVisibility(postData.visibility);
47
55
 
48
56
  const event = postData.data.type === 'event' ? postData.data : null;
@@ -110,6 +118,7 @@ export const useNewEvent = () => {
110
118
  return {
111
119
  postData,
112
120
  setPostData,
121
+ canCreate,
113
122
  canSubmit,
114
123
  submitting,
115
124
  error,
@@ -10,6 +10,10 @@ export function AdminConfigurationCommunity() {
10
10
  translationPrefix="configuration.community.info"
11
11
  action="/admin/configuration/community/info"
12
12
  />
13
+ <ConfigMenuButton
14
+ translationPrefix="configuration.community.access"
15
+ action="/admin/configuration/community/access"
16
+ />
13
17
  <ConfigMenuButton
14
18
  translationPrefix="configuration.community.favicons"
15
19
  action="/admin/configuration/community/favicons"
@@ -0,0 +1,129 @@
1
+ import { useState } from 'react';
2
+ import { type CoreConfig, type ConfigTree } from '@openpeepshq/common/types';
3
+ import {
4
+ useT,
5
+ useSetPageHeader,
6
+ useOpenpeeps,
7
+ diffConfigTrees,
8
+ } from '../../../index';
9
+ import { Label, Switch, Toast } from '@openpeepshq/react-ui';
10
+
11
+ /**
12
+ * Open signups and public content live in the `openpeeps.core` config under
13
+ * `server.*`, but are surfaced here (under Community Customization) so an
14
+ * admin can update them without opening the raw Server settings tree editor.
15
+ */
16
+ export function AdminConfigurationCommunityAccess() {
17
+ const t = useT();
18
+ const { openpeepsApi } = useOpenpeeps();
19
+ const configQuery = openpeepsApi.admin.useConfigRead('openpeeps', 'core');
20
+ const updateConfig = openpeepsApi.admin.updateConfigAction({
21
+ namespace: 'openpeeps',
22
+ name: 'core',
23
+ });
24
+
25
+ useSetPageHeader(
26
+ t('configuration.community.access.title', { defaultValue: 'Access' }),
27
+ );
28
+
29
+ const base = configQuery.data?.config as CoreConfig | undefined;
30
+ const [status, setStatus] = useState<{
31
+ type: 'success' | 'error';
32
+ message: string;
33
+ } | null>(null);
34
+
35
+ const signUpsOpen = base?.server?.signUpsOpen ?? true;
36
+ const publicContent = base?.server?.publicContent ?? false;
37
+
38
+ const persist = async (patch: CoreConfig['server']) => {
39
+ if (!base) return;
40
+ setStatus(null);
41
+ try {
42
+ const diff = diffConfigTrees(
43
+ base.server as unknown as ConfigTree,
44
+ patch as unknown as ConfigTree,
45
+ );
46
+ if (Object.keys(diff).length === 0) return;
47
+ await updateConfig({
48
+ config: { server: diff } as Partial<CoreConfig>,
49
+ });
50
+ setStatus({
51
+ type: 'success',
52
+ message: t('configuration.community.access.updated', {
53
+ defaultValue: 'Access settings updated',
54
+ }),
55
+ });
56
+ } catch (err) {
57
+ setStatus({ type: 'error', message: (err as Error).message });
58
+ }
59
+ };
60
+
61
+ if (configQuery.isLoading || !base) {
62
+ return (
63
+ <div className="text-muted-foreground flex h-32 items-center justify-center text-sm">
64
+ {t('common.form.loading', { defaultValue: 'Loading…' })}
65
+ </div>
66
+ );
67
+ }
68
+
69
+ return (
70
+ <div className="space-y-6 p-4">
71
+ <p className="text-muted-foreground text-sm">
72
+ {t('configuration.community.access.description', {
73
+ defaultValue:
74
+ 'Control who can join your community and who can see it',
75
+ })}
76
+ </p>
77
+
78
+ <Label
79
+ title={t('configuration.community.openRegistrations.title', {
80
+ defaultValue: 'Open Signups',
81
+ })}
82
+ description={t(
83
+ 'configuration.community.openRegistrations.description',
84
+ {
85
+ defaultValue: 'Allow visitors to sign up for the community',
86
+ },
87
+ )}
88
+ forCheckbox
89
+ >
90
+ <Switch
91
+ checked={signUpsOpen}
92
+ onCheckedChange={(next) =>
93
+ void persist({ ...base.server, signUpsOpen: next })
94
+ }
95
+ data-testid="admin-community-access-signups"
96
+ />
97
+ </Label>
98
+
99
+ <Label
100
+ title={t('configuration.community.publicContent.title', {
101
+ defaultValue: 'Public content',
102
+ })}
103
+ description={t('configuration.community.publicContent.description', {
104
+ defaultValue:
105
+ 'Allow visitors to read public posts without an account',
106
+ })}
107
+ forCheckbox
108
+ >
109
+ <Switch
110
+ checked={publicContent}
111
+ onCheckedChange={(next) =>
112
+ void persist({ ...base.server, publicContent: next })
113
+ }
114
+ data-testid="admin-community-access-public-content"
115
+ />
116
+ </Label>
117
+
118
+ {status ? (
119
+ <Toast
120
+ variant={status.type}
121
+ testId="admin-community-access-toast"
122
+ onDismiss={() => setStatus(null)}
123
+ >
124
+ {status.message}
125
+ </Toast>
126
+ ) : null}
127
+ </div>
128
+ );
129
+ }
@@ -1,4 +1,5 @@
1
1
  import { useMemo, useState, type ReactNode } from 'react';
2
+ import { useNavigate } from 'react-router-dom';
2
3
  import { MessageCircleOff, Calendar, MessageSquarePlus } from 'lucide-react';
3
4
  import type { PublicPost } from '@openpeepshq/common/types';
4
5
  import {
@@ -14,6 +15,7 @@ import {
14
15
  } from '../../index';
15
16
  import {
16
17
  Avatar,
18
+ DirectMessageSearch,
17
19
  PostMarkdown,
18
20
  useAuthData,
19
21
  useCurrentProfile,
@@ -121,6 +123,7 @@ function TabButton({
121
123
 
122
124
  export function ConversationsIndex() {
123
125
  const t = useT();
126
+ const navigate = useNavigate();
124
127
  const { openpeepsApi } = useOpenpeeps();
125
128
  const { openCreateConversation } = useCreateNewConversation();
126
129
  const authData = useAuthData();
@@ -131,6 +134,8 @@ export function ConversationsIndex() {
131
134
 
132
135
  const canCreate = canCreatePost(authData, 'note', 'direct');
133
136
  const [tab, setTab] = useState<ConversationsTab>('active');
137
+ const [messageSearch, setMessageSearch] = useState('');
138
+ const searching = messageSearch.trim().length >= 2;
134
139
 
135
140
  const conversations =
136
141
  (tab === 'active' ? query.data : archivedQuery.data) ?? [];
@@ -192,39 +197,53 @@ export function ConversationsIndex() {
192
197
  );
193
198
 
194
199
  return (
195
- <AccessDeniedLoader queries={[activeQuery]}>
196
- {conversations.length === 0 ? (
197
- <div className="flex h-[80vh] items-center justify-center gap-2">
198
- <MessageCircleOff size={40} />
199
- <p className="text-muted-foreground">
200
- {t('conversations.empty', {
201
- defaultValue: 'No direct messages here',
202
- })}
203
- </p>
204
- </div>
205
- ) : (
206
- <div>
207
- {conversations.map((conversation) => {
208
- const first = conversation[0];
209
- if (!first) return null;
210
- return (
211
- <a
212
- key={first.id}
213
- href={`/conversations/${first.id}`}
214
- className="hover:bg-surface block text-left transition-all"
215
- title={t('conversations.open', {
216
- defaultValue: 'Open conversation',
217
- })}
218
- >
219
- <ChatPreview
220
- conversation={conversation}
221
- unreadCount={unseenByConversation[first.id] ?? 0}
222
- />
223
- </a>
200
+ <div>
201
+ {activeQuery.isError ? null : (
202
+ <DirectMessageSearch
203
+ onQueryChange={setMessageSearch}
204
+ onSelect={(hit) => {
205
+ navigate(
206
+ `/conversations/${hit.conversationId}?message=${hit.message.id}`,
224
207
  );
225
- })}
226
- </div>
208
+ }}
209
+ />
210
+ )}
211
+ {searching ? null : (
212
+ <AccessDeniedLoader queries={[activeQuery]}>
213
+ {conversations.length === 0 ? (
214
+ <div className="flex h-[80vh] items-center justify-center gap-2">
215
+ <MessageCircleOff size={40} />
216
+ <p className="text-muted-foreground">
217
+ {t('conversations.empty', {
218
+ defaultValue: 'No direct messages here',
219
+ })}
220
+ </p>
221
+ </div>
222
+ ) : (
223
+ <div>
224
+ {conversations.map((conversation) => {
225
+ const first = conversation[0];
226
+ if (!first) return null;
227
+ return (
228
+ <a
229
+ key={first.id}
230
+ href={`/conversations/${first.id}`}
231
+ className="hover:bg-surface block text-left transition-all"
232
+ title={t('conversations.open', {
233
+ defaultValue: 'Open conversation',
234
+ })}
235
+ >
236
+ <ChatPreview
237
+ conversation={conversation}
238
+ unreadCount={unseenByConversation[first.id] ?? 0}
239
+ />
240
+ </a>
241
+ );
242
+ })}
243
+ </div>
244
+ )}
245
+ </AccessDeniedLoader>
227
246
  )}
228
- </AccessDeniedLoader>
247
+ </div>
229
248
  );
230
249
  }