Skip to content

Commit ca1d53b

Browse files
committed
chore(demo): show ChannelPreviewOverlay always if not a member
1 parent eeefd87 commit ca1d53b

3 files changed

Lines changed: 43 additions & 84 deletions

File tree

examples/vite/src/PublicChannelOverlay/PublicChannelOverlay.scss renamed to examples/vite/src/ChannelPreviewOverlay/ChannelPreviewOverlay.scss

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.app-public-channel-overlay {
1+
.app-channel-preview-overlay {
22
position: absolute;
33
inset: 0;
44
z-index: 3;
@@ -14,7 +14,7 @@
1414
}
1515
}
1616

17-
.app-public-channel-overlay__content {
17+
.app-channel-preview-overlay__content {
1818
position: relative;
1919
display: flex;
2020
flex-direction: column;
@@ -53,7 +53,7 @@
5353
}
5454
}
5555

56-
.app-public-channel-overlay__text {
56+
.app-channel-preview-overlay__text {
5757
display: flex;
5858
flex-direction: column;
5959
align-items: center;
@@ -66,39 +66,22 @@
6666
}
6767
}
6868

69-
.app-public-channel-overlay__title {
69+
.app-channel-preview-overlay__title {
7070
font: var(--str-chat__font-heading-xs);
7171
color: var(--str-chat__text-color);
7272
}
7373

74-
.app-public-channel-overlay__description {
74+
.app-channel-preview-overlay__description {
7575
font: var(--str-chat__font-caption-default);
7676
color: var(--str-chat__text-secondary);
7777
max-width: 200px;
7878
}
7979

80-
.app-public-channel-overlay__join-button {
80+
.app-channel-preview-overlay__join-button {
8181
width: 106px;
8282

8383
.str-chat__loading-indicator {
8484
height: 20px;
8585
width: 20px;
8686
}
8787
}
88-
89-
.app-public-channel-composer-banner {
90-
display: flex;
91-
align-items: center;
92-
justify-content: center;
93-
width: 100%;
94-
min-height: 56px;
95-
padding: 16px;
96-
border-top: 1px solid var(--str-chat__border-color);
97-
}
98-
99-
.app-public-channel-composer-banner__text {
100-
margin: 0;
101-
font: var(--str-chat__font-caption-default);
102-
color: var(--str-chat__text-secondary);
103-
text-align: center;
104-
}

examples/vite/src/PublicChannelOverlay/PublicChannelOverlay.tsx renamed to examples/vite/src/ChannelPreviewOverlay/ChannelPreviewOverlay.tsx

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import {
1010
useNotificationApi,
1111
} from 'stream-chat-react';
1212

13-
import './PublicChannelOverlay.scss';
13+
import './ChannelPreviewOverlay.scss';
1414

15-
export const usePublicChannelState = () => {
15+
export const useChannelMembershipState = () => {
1616
const { client } = useChatContext();
1717
const { channel } = useChannelStateContext();
1818
const members = useChannelMembersState(channel);
@@ -24,8 +24,8 @@ export const usePublicChannelState = () => {
2424
return { canJoin, channel, client, isMember };
2525
};
2626

27-
export const PublicChannelOverlay = () => {
28-
const { canJoin, channel, client, isMember } = usePublicChannelState();
27+
export const ChannelPreviewOverlay = () => {
28+
const { canJoin, channel, client, isMember } = useChannelMembershipState();
2929
const { addNotification } = useNotificationApi();
3030
const [joining, setJoining] = useState(false);
3131

@@ -35,7 +35,7 @@ export const PublicChannelOverlay = () => {
3535
await channel.addMembers([client.userID!]);
3636
} catch (error) {
3737
addNotification({
38-
emitter: 'PublicChannelOverlay',
38+
emitter: 'ChannelPreviewOverlay',
3939
incident: {
4040
domain: 'api',
4141
entity: 'channel',
@@ -50,45 +50,35 @@ export const PublicChannelOverlay = () => {
5050
}
5151
}, [addNotification, channel, client.userID]);
5252

53-
if (isMember || !canJoin) return null;
53+
if (isMember) return null;
5454

5555
return (
56-
<div className='app-public-channel-overlay'>
57-
<div className='app-public-channel-overlay__content'>
56+
<div className='app-channel-preview-overlay'>
57+
<div className='app-channel-preview-overlay__content'>
5858
<IconMessageBubbles />
59-
<div className='app-public-channel-overlay__text'>
60-
<p className='app-public-channel-overlay__title'>
61-
You're previewing this group
59+
<div className='app-channel-preview-overlay__text'>
60+
<p className='app-channel-preview-overlay__title'>
61+
{canJoin ? "You're previewing this group" : 'This is a private group'}
6262
</p>
63-
<p className='app-public-channel-overlay__description'>
64-
Join to send messages and follow the conversation
63+
<p className='app-channel-preview-overlay__description'>
64+
{canJoin
65+
? 'Join to send messages and follow the conversation'
66+
: 'It is not possible to join this group'}
6567
</p>
6668
</div>
67-
<Button
68-
appearance='solid'
69-
className='app-public-channel-overlay__join-button'
70-
disabled={joining}
71-
onClick={handleJoin}
72-
size='md'
73-
variant='primary'
74-
>
75-
{joining ? <LoadingIndicator /> : 'Join Group'}
76-
</Button>
69+
{canJoin && (
70+
<Button
71+
appearance='solid'
72+
className='app-channel-preview-overlay__join-button'
73+
disabled={joining}
74+
onClick={handleJoin}
75+
size='md'
76+
variant='primary'
77+
>
78+
{joining ? <LoadingIndicator /> : 'Join Group'}
79+
</Button>
80+
)}
7781
</div>
7882
</div>
7983
);
8084
};
81-
82-
export const PublicChannelComposerBanner = () => {
83-
const { canJoin, isMember } = usePublicChannelState();
84-
85-
if (isMember || canJoin) return null;
86-
87-
return (
88-
<div className='app-public-channel-composer-banner'>
89-
<p className='app-public-channel-composer-banner__text'>
90-
You can only view this conversation
91-
</p>
92-
</div>
93-
);
94-
};

examples/vite/src/ChatLayout/Panels.tsx

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ import { useAppSettingsSelector } from '../AppSettings/state';
2727
import { DESKTOP_LAYOUT_BREAKPOINT } from './constants.ts';
2828
import { SidebarResizeHandle, ThreadResizeHandle } from './Resize.tsx';
2929
import { ReturnToSkipNavigation } from '../AccessibilityNavigation/ReturnToSkipNavigation.tsx';
30-
import {
31-
PublicChannelComposerBanner,
32-
PublicChannelOverlay,
33-
usePublicChannelState,
34-
} from '../PublicChannelOverlay/PublicChannelOverlay.tsx';
30+
import { ChannelPreviewOverlay } from '../ChannelPreviewOverlay/ChannelPreviewOverlay.tsx';
3531
import { useSidebar } from './SidebarContext.tsx';
3632
import { ThreadStateSync } from './Sync.tsx';
3733

@@ -66,23 +62,6 @@ const ChannelThreadPanel = () => {
6662
);
6763
};
6864

69-
const MessageComposerOrBanner = () => {
70-
const { canJoin, isMember } = usePublicChannelState();
71-
72-
if (!isMember && !canJoin) return <PublicChannelComposerBanner />;
73-
74-
return (
75-
<MessageComposer
76-
additionalTextareaProps={{
77-
id: CHANNEL_MESSAGE_COMPOSER_TEXTAREA_TARGET_ID,
78-
}}
79-
audioRecordingEnabled
80-
maxRows={10}
81-
asyncMessagesMultiSendEnabled
82-
/>
83-
);
84-
};
85-
8665
const ResponsiveChannelPanels = () => {
8766
const { thread } = useChannelStateContext('ResponsiveChannelPanels');
8867
const isThreadOpen = !!thread;
@@ -105,8 +84,15 @@ const ResponsiveChannelPanels = () => {
10584
)}
10685
<ReturnToSkipNavigation />
10786
<AIStateIndicator />
108-
<MessageComposerOrBanner />
109-
<PublicChannelOverlay />
87+
<MessageComposer
88+
additionalTextareaProps={{
89+
id: CHANNEL_MESSAGE_COMPOSER_TEXTAREA_TARGET_ID,
90+
}}
91+
audioRecordingEnabled
92+
maxRows={10}
93+
asyncMessagesMultiSendEnabled
94+
/>
95+
<ChannelPreviewOverlay />
11096
</div>
11197
</Window>
11298
</WithDragAndDropUpload>

0 commit comments

Comments
 (0)