@openpeepshq/rn-components 0.6.5 → 0.6.7

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.6.5",
3
+ "version": "0.6.7",
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.3.2",
146
- "@openpeepshq/react": "^0.6.1"
146
+ "@openpeepshq/react": "^0.6.2"
147
147
  },
148
148
  "devDependencies": {
149
149
  "@babel/core": "^7.26.7",
@@ -1,14 +1,18 @@
1
1
  import { View, Image, TouchableOpacity, ActivityIndicator } from 'react-native';
2
- import React, { useMemo } from 'react';
2
+ import React from 'react';
3
3
  import { ThemedText } from '../../../ui/themed-text';
4
- import { Event, PublicPost, PublicRsvp } from '@openpeepshq/common';
4
+ import { Event, PublicPost } from '@openpeepshq/common';
5
5
  import { truncateText } from '../../../../lib/utils';
6
- import { formatEventRecurrence } from '@openpeepshq/common/lib';
7
- import { useOpenpeeps } from '@openpeepshq/react';
6
+ import { canModerateJam, formatEventRecurrence } from '@openpeepshq/common/lib';
7
+ import {
8
+ useOpenpeeps,
9
+ useCurrentProfile,
10
+ useServerInfo,
11
+ } from '@openpeepshq/react';
8
12
  import { useNavigation } from '@react-navigation/native';
9
13
  import { NativeStackNavigationProp } from '@react-navigation/native-stack';
10
14
  import { MainStackParamList } from '../../../navigation/types/index';
11
- import { calculateEffectiveRsvps } from '../../../../lib/utils';
15
+ import { Button } from '../../../ui/button';
12
16
  import { Timespan } from '../../../custom/date/index';
13
17
  import { EventLocation } from '../../pieces/EventLocation';
14
18
  import { ProfileEventRelationship } from './ProfileEventRelationship';
@@ -24,6 +28,8 @@ export interface CardEventProps {
24
28
  export const CardEvent = ({ post, showEventDate = true }: CardEventProps) => {
25
29
  const { openpeepsApi } = useOpenpeeps();
26
30
  const { t } = useTranslation();
31
+ const me = useCurrentProfile();
32
+ const livekitEnabled = useServerInfo().jams.livekit.enabled;
27
33
 
28
34
  const event = post.data as Event;
29
35
  const jam = event.jam;
@@ -34,9 +40,7 @@ export const CardEvent = ({ post, showEventDate = true }: CardEventProps) => {
34
40
  );
35
41
  const navigation =
36
42
  useNavigation<NativeStackNavigationProp<MainStackParamList>>();
37
- const rsvps = useMemo<PublicRsvp[]>(() => {
38
- return calculateEffectiveRsvps(post, occurrenceId) || [];
39
- }, [post, occurrenceId]);
43
+ const attendeesLength = jamState?.participants.length ?? 0;
40
44
 
41
45
  return (
42
46
  <TouchableOpacity
@@ -81,32 +85,53 @@ export const CardEvent = ({ post, showEventDate = true }: CardEventProps) => {
81
85
  <EventLocation post={post} truncate={true} />
82
86
  <ProfileEventRelationship post={post} />
83
87
  </View>
84
- {jam && (
85
- <View className="flex w-full">
86
- {isLoading && <ActivityIndicator size={'small'} />}
87
- {!isLoading && jamState && (
88
- <View
89
- className={`flex justify-start ${
90
- jamState?.participants?.length || 0 > 1 ? 'gap-5' : 'gap-2'
88
+ {jam && me && livekitEnabled ? (
89
+ isLoading ? (
90
+ <ActivityIndicator size="small" />
91
+ ) : jamState?.active ? (
92
+ <View className="flex flex-row items-center gap-x-2 text-xs text-muted-foreground">
93
+ <View className="w-12">
94
+ <ParticipantsCard jamState={jamState} />
95
+ </View>
96
+ <ThemedText>
97
+ {attendeesLength}{' '}
98
+ {attendeesLength === 1
99
+ ? t('events.jam.attendee', { defaultValue: 'attendee' })
100
+ : t('events.jam.attendees', {
101
+ defaultValue: 'attendees',
102
+ })}
103
+ </ThemedText>
104
+ <Button
105
+ variant="default"
106
+ size="sm"
107
+ onPress={() =>
108
+ navigation.navigate('JamSession', {
109
+ jamId: post.id,
110
+ occurrence: occurrenceId,
111
+ })
91
112
  }
92
- text-muted-foreground text-xs ${
93
- (jamState?.participants?.length ?? 0) > 0 ? '-mt-4' : ''
94
- }`}
95
113
  >
96
- <View className="flex flex-row items-center gap-x-2">
97
- {jamState?.participants?.length > 0 && (
98
- <View className="flex-row items-center">
99
- <ParticipantsCard jamState={jamState} />
100
- </View>
101
- )}
102
- <ThemedText>
103
- {rsvps.length} {rsvps?.length === 1 ? 'rsvp' : 'rsvps'}
104
- </ThemedText>
105
- </View>
106
- </View>
107
- )}
108
- </View>
109
- )}
114
+ <ThemedText numberOfLines={1}>
115
+ {t('jam.join.submit', { defaultValue: 'Join Jam' })}
116
+ </ThemedText>
117
+ </Button>
118
+ </View>
119
+ ) : canModerateJam(me, post) ? (
120
+ <Button
121
+ className="mt-2 w-full"
122
+ onPress={() =>
123
+ navigation.navigate('JamSession', {
124
+ jamId: post.id,
125
+ occurrence: occurrenceId,
126
+ })
127
+ }
128
+ >
129
+ <ThemedText numberOfLines={1}>
130
+ {t('jam.start.submit', { defaultValue: 'Start Jam' })}
131
+ </ThemedText>
132
+ </Button>
133
+ ) : null
134
+ ) : null}
110
135
  </View>
111
136
  </TouchableOpacity>
112
137
  );
@@ -1,5 +1,5 @@
1
1
  import React, { useMemo, useRef } from 'react';
2
- import { useOpenpeeps } from '@openpeepshq/react';
2
+ import { useOpenpeeps, useServerInfo } from '@openpeepshq/react';
3
3
  import {
4
4
  MoreVerticalIcon,
5
5
  ShareIcon,
@@ -125,13 +125,15 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
125
125
  navigation.navigate('SelectPrivateMessageMembers');
126
126
  };
127
127
 
128
- const { data: serverInfo } = openpeepsApi.useServerInfo();
129
- const livekitEnabled = !!serverInfo?.jams.livekit.enabled;
128
+ const serverInfo = useServerInfo();
129
+ const livekitEnabled = serverInfo.jams.livekit.enabled;
130
130
  const myEvent = currentProfile?.id === post?.profile?.id;
131
131
  const iAmModerator = canModerateJam(currentProfile, post);
132
132
  const canExportAttendees = canViewJamAttendees(currentProfile, post);
133
133
  const canViewRecordings = canAccessJamRecordings(currentProfile, post);
134
134
  const jamAttendeesQuery = openpeepsApi.useJamAttendance(post.id);
135
+ const jamStateQuery = openpeepsApi.useJamState(post.id, occurrence);
136
+ const jamState = event.jam ? jamStateQuery.data : undefined;
135
137
  const recordingsQuery = openpeepsApi.usePostRecordings(
136
138
  post.id,
137
139
  !!event.jam && canViewRecordings
@@ -347,19 +349,41 @@ export const FullEvent: React.FC<FullEventProps> = ({ post, occurrence }) => {
347
349
  <EventRsvpButton post={post as PublicPost} recurrenceId={occurrence} />
348
350
  {event.jam && (myEvent || iAmModerator) ? (
349
351
  livekitEnabled ? (
350
- <Button
351
- className="mt-2 w-full"
352
- onPress={() =>
353
- navigation.navigate('JamSession', { jamId: post.id })
354
- }
355
- >
356
- <ThemedText numberOfLines={1}>
357
- {t('events.jam.start', { defaultValue: 'Start jam' })}
358
- </ThemedText>
359
- </Button>
352
+ jamState?.active ? (
353
+ <Button
354
+ className="mt-2 w-full"
355
+ onPress={() =>
356
+ navigation.navigate('JamSession', {
357
+ jamId: post.id,
358
+ occurrence: occurrence,
359
+ })
360
+ }
361
+ >
362
+ <ThemedText numberOfLines={1}>
363
+ {t('jam.join.submit', { defaultValue: 'Join Jam' })}
364
+ </ThemedText>
365
+ </Button>
366
+ ) : (
367
+ <Button
368
+ className="mt-2 w-full"
369
+ onPress={() =>
370
+ navigation.navigate('JamSession', {
371
+ jamId: post.id,
372
+ occurrence: occurrence,
373
+ })
374
+ }
375
+ >
376
+ <ThemedText numberOfLines={1}>
377
+ {t('events.jam.start', { defaultValue: 'Start jam' })}
378
+ </ThemedText>
379
+ </Button>
380
+ )
360
381
  ) : (
361
382
  <ThemedText className="mt-2 text-sm text-destructive">
362
- {t('jams.unavailable.message')}
383
+ {t('jams.unavailable.message', {
384
+ defaultValue:
385
+ 'Jams are unavailable because LiveKit is not connected.',
386
+ })}
363
387
  </ThemedText>
364
388
  )
365
389
  ) : null}
@@ -1,6 +1,6 @@
1
1
  import { cva, type VariantProps } from 'class-variance-authority';
2
2
  import * as React from 'react';
3
- import { Pressable, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { Pressable } from 'react-native';
4
4
  import { TextClassContext } from './themed-text';
5
5
  import { cn } from '../../lib/utils';
6
6
  import { useThemeBorderRadius } from '../../theme/OpenPeepsThemeProvider';
@@ -85,7 +85,11 @@ const Button = React.forwardRef<
85
85
  )}
86
86
  ref={ref}
87
87
  role="button"
88
- style={cn({ borderRadius }, style) as StyleProp<ViewStyle>}
88
+ style={
89
+ typeof style === 'function'
90
+ ? (s: { pressed: boolean }) => [{ borderRadius }, style(s)]
91
+ : [{ borderRadius }, style]
92
+ }
89
93
  {...props}
90
94
  />
91
95
  </TextClassContext.Provider>