@openpeepshq/rn-components 0.8.1 → 0.8.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpeepshq/rn-components",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
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",
@@ -143,7 +143,7 @@
143
143
  "validator": "^13.15.23",
144
144
  "zustand": "^5.0.3",
145
145
  "@openpeepshq/common": "^0.4.0",
146
- "@openpeepshq/react": "^0.8.1"
146
+ "@openpeepshq/react": "^0.8.4"
147
147
  },
148
148
  "devDependencies": {
149
149
  "@babel/core": "^7.26.7",
@@ -11,7 +11,7 @@ import { BASE_URL } from '../../../lib/constants';
11
11
  export const linkRenderer =
12
12
  (handleLinkPress: (url: string) => void): RenderFunction =>
13
13
  (node, children, _parentNodes, styles) => {
14
- const href = (node as { url?: string }).url || '';
14
+ const href = node.attributes.href || '';
15
15
  const origin = BASE_URL as string;
16
16
  const isExternal = isExternalLink(href, origin);
17
17
 
@@ -37,7 +37,7 @@ export const EventLocation: React.FC<EventLocationProps> = ({
37
37
  <>
38
38
  <LinkIcon className="text-muted-foreground" size={18} />
39
39
  <ThemedText className="text-muted-foreground">
40
- {t('events.location.online', { defaultValue: 'Online' })}
40
+ {t('events.location.external', { defaultValue: 'External Event' })}
41
41
  </ThemedText>
42
42
  </>
43
43
  ) : null}
@@ -211,14 +211,18 @@ export const ResourceForm = ({
211
211
  </>
212
212
  ) : (
213
213
  <>
214
- <Pressable
215
- onPress={openMedia}
216
- className="items-center rounded-md border border-input px-3 py-2"
217
- >
218
- <ThemedText>
219
- {t('resources.form.addMedia', { defaultValue: 'Add files' })}
220
- </ThemedText>
221
- </Pressable>
214
+ {/* Only galleries take more than one file; other kinds pick once. */}
215
+ {resource.resourceKind === 'gallery' ||
216
+ (resource.attachments ?? []).length === 0 ? (
217
+ <Pressable
218
+ onPress={openMedia}
219
+ className="items-center rounded-md border border-input px-3 py-2"
220
+ >
221
+ <ThemedText>
222
+ {t('resources.form.addMedia', { defaultValue: 'Add files' })}
223
+ </ThemedText>
224
+ </Pressable>
225
+ ) : null}
222
226
  <ComposeAttachments
223
227
  attachments={resource.attachments ?? []}
224
228
  removeAttachment={(index) =>
@@ -27,6 +27,7 @@ import {
27
27
  BookmarkMinusIcon,
28
28
  LinkIcon,
29
29
  ImageOffIcon,
30
+ AudioLinesIcon,
30
31
  } from '../icons';
31
32
 
32
33
  export interface ResourceCardProps {
@@ -39,8 +40,12 @@ export interface ResourceCardProps {
39
40
  inGroup?: boolean;
40
41
  }
41
42
 
43
+ // Audio attachments render their generated waveform preview like any other
44
+ // visual; without one they fall back to the kind placeholder below.
42
45
  const visualAttachments = (attachments: MediaAttachmentData[]) =>
43
- attachments.filter((att) => attachmentMediaKind(att) !== 'audio');
46
+ attachments.filter(
47
+ (att) => attachmentMediaKind(att) !== 'audio' || !!att.previewUrl
48
+ );
44
49
 
45
50
  const primaryActionLabel = (
46
51
  kind: ResourceKind,
@@ -170,6 +175,13 @@ export const ResourceCard = ({
170
175
  <CachedImage url={thumbSrc} className="h-12 w-12" resizeMode="cover" />
171
176
  );
172
177
  }
178
+ if (resource.resourceKind === 'audio') {
179
+ return (
180
+ <View className="h-12 w-12 items-center justify-center rounded-md bg-muted">
181
+ <AudioLinesIcon size={20} className="text-muted-foreground" />
182
+ </View>
183
+ );
184
+ }
173
185
  if (resource.resourceKind === 'link' && resource.url) {
174
186
  return (
175
187
  <View className="h-12 w-12 items-center justify-center rounded-md bg-muted">
@@ -286,6 +298,10 @@ export const ResourceCard = ({
286
298
  );
287
299
  })}
288
300
  </View>
301
+ ) : resource.resourceKind === 'audio' ? (
302
+ <View className="h-48 w-full items-center justify-center rounded-md bg-muted">
303
+ <AudioLinesIcon size={32} className="text-muted-foreground/50" />
304
+ </View>
289
305
  ) : resource.resourceKind === 'link' && resource.url ? (
290
306
  <View className="h-48 w-full items-center justify-center rounded-md bg-muted">
291
307
  <LinkIcon size={32} className="text-muted-foreground/50" />
@@ -8,7 +8,7 @@ import {
8
8
  import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
9
9
  import { CompositeScreenProps } from '@react-navigation/native';
10
10
  import { NativeStackScreenProps } from '@react-navigation/native-stack';
11
- import { checkRoleCapabilities } from '@openpeepshq/common';
11
+ import { canCreateGroup } from '@openpeepshq/common';
12
12
  import { useOpenpeeps } from '@openpeepshq/react';
13
13
  import { useTranslation } from 'react-i18next';
14
14
  import {
@@ -60,9 +60,7 @@ export const GroupsIndex: React.FC<GroupsProps> = ({ navigation }) => {
60
60
  [groups, isMember, search, tab]
61
61
  );
62
62
 
63
- const canCreate = checkRoleCapabilities(currentProfile?.roles ?? [], [
64
- 'core-groups-create',
65
- ]).success;
63
+ const canCreate = canCreateGroup(currentProfile?.roles ?? []);
66
64
 
67
65
  useSetPageHeader(t('navigation.groups', { defaultValue: 'Groups' }));
68
66
  useSetPlusButtonActions(
@@ -13,7 +13,7 @@ import { Label } from '../../components/ui/label';
13
13
 
14
14
  type NewGroupProps = MainScreenProps<'CreateGroup'>;
15
15
 
16
- export const NewGroup: React.FC<NewGroupProps> = () => {
16
+ export const NewGroup: React.FC<NewGroupProps> = ({ navigation }) => {
17
17
  const { t } = useTranslation();
18
18
  const me = useCurrentProfile();
19
19
  const {
@@ -25,6 +25,7 @@ export const NewGroup: React.FC<NewGroupProps> = () => {
25
25
  error,
26
26
  clearError,
27
27
  fieldErrors,
28
+ canCreate,
28
29
  submit,
29
30
  } = useNewGroup();
30
31
 
@@ -34,20 +35,32 @@ export const NewGroup: React.FC<NewGroupProps> = () => {
34
35
  clearError();
35
36
  }, [error, clearError]);
36
37
 
38
+ React.useEffect(() => {
39
+ if (me && !canCreate) {
40
+ navigation.navigate('TabNavigator', { screen: 'Groups' });
41
+ }
42
+ }, [canCreate, me, navigation]);
43
+
37
44
  useSetPageHeader(
38
- t('groups.new.title', { defaultValue: 'Create group' }),
39
- <HeaderActionButton
40
- title={
41
- submitting
42
- ? t('common.submitting', { defaultValue: 'Creating…' })
43
- : t('common.submit', { defaultValue: 'Create group' })
44
- }
45
- onPress={() => void submit()}
46
- disabled={submitting}
47
- loading={submitting}
48
- />
45
+ canCreate
46
+ ? t('groups.new.title', { defaultValue: 'Create group' })
47
+ : undefined,
48
+ canCreate ? (
49
+ <HeaderActionButton
50
+ title={
51
+ submitting
52
+ ? t('common.submitting', { defaultValue: 'Creating…' })
53
+ : t('common.submit', { defaultValue: 'Create group' })
54
+ }
55
+ onPress={() => void submit()}
56
+ disabled={submitting}
57
+ loading={submitting}
58
+ />
59
+ ) : undefined
49
60
  );
50
61
 
62
+ if (!canCreate) return null;
63
+
51
64
  return (
52
65
  <ThemedView className="flex-1">
53
66
  <KeyboardAwareScrollView