Skip to content

Commit bbaaf9c

Browse files
authored
Merge pull request #37 from FrostCord/FROS-Media-Channels
Add Media Channel Support
2 parents 908c6cd + 08a8a10 commit bbaaf9c

4 files changed

Lines changed: 32 additions & 4 deletions

File tree

components/home/Server.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import styles from '@/styles/Servers.module.css';
99
import Marquee from 'react-fast-marquee';
1010
import { getServerMemberCount, getUsersInServer } from '@/services/server.service';
1111
import { Channel, Server as ServerType } from '@/types/dbtypes';
12+
import { ChannelMediaIcon } from '../icons/ChannelMediaIcon';
1213

1314
export default function Server({ server, expanded }: { server: ServerType, expanded: number }) {
1415
const expand = expanded == server.id;
@@ -52,7 +53,7 @@ export default function Server({ server, expanded }: { server: ServerType, expan
5253
handleAsync();
5354
}, [server, supabase, onlinePresenceChannel]);
5455

55-
function joinChannel(e: SyntheticEvent, channelId: number, name: string) {
56+
function joinTextChannel(e: SyntheticEvent, channelId: number, name: string) {
5657
e.stopPropagation();
5758
setChatName(name);
5859
setChannelId(channelId);
@@ -117,11 +118,20 @@ export default function Server({ server, expanded }: { server: ServerType, expan
117118
className={`channel flex whitespace-nowrap items-center pt-2 pb-1 px-4 hover:bg-grey-600 hover:cursor-pointer rounded-lg max-w-[192px] ${
118119
idx === 0 ? 'mt-2' : ''
119120
}`}
120-
onClick={(e) => joinChannel(e, channel.channel_id, channel.name)}
121+
onClick={(e) => {
122+
if (channel.is_media) {
123+
// Entrypoint for media channel
124+
return;
125+
}
126+
127+
else {
128+
joinTextChannel(e, channel.channel_id, channel.name);
129+
}
130+
}}
121131
key={channel.channel_id}
122132
>
123133
<div className="w-4">
124-
<ChannelMessageIcon size="" />
134+
{channel.is_media ? <ChannelMediaIcon/> : <ChannelMessageIcon/>}
125135
</div>
126136

127137
<div className="ml-2 text-sm font-semibold tracking-wide text-grey-200 max-w-[10ch] overflow-hidden hover:overflow-visible">
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export function ChannelMediaIcon({ size = 4 }: { size?: number }) {
2+
return (
3+
<svg
4+
xmlns="http://www.w3.org/2000/svg"
5+
fill="none"
6+
viewBox="0 0 256 256"
7+
strokeWidth={2}
8+
stroke="currentColor"
9+
className={`w-${size} h-${size}`}
10+
>
11+
<path
12+
fill="currentColor"
13+
d="M155.51 24.81a8 8 0 0 0-8.42.88L77.25 80H32a16 16 0 0 0-16 16v64a16 16 0 0 0 16 16h45.25l69.84 54.31A8 8 0 0 0 160 224V32a8 8 0 0 0-4.49-7.19ZM32 96h40v64H32Zm112 111.64l-56-43.55V91.91l56-43.55Zm54-106.08a40 40 0 0 1 0 52.88a8 8 0 0 1-12-10.58a24 24 0 0 0 0-31.72a8 8 0 0 1 12-10.58ZM248 128a79.9 79.9 0 0 1-20.37 53.34a8 8 0 0 1-11.92-10.67a64 64 0 0 0 0-85.33a8 8 0 1 1 11.92-10.67A79.83 79.83 0 0 1 248 128Z"
14+
/>
15+
</svg>
16+
);
17+
}

components/icons/ChannelMessageIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function ChannelMessageIcon({ size = '4' }) {
1+
export default function ChannelMessageIcon({ size = '4' }: { size?: string }) {
22
return (
33
<svg
44
xmlns="http://www.w3.org/2000/svg"

services/channels.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export async function getChannelsInServer(supabase: SupabaseClient<Database>, se
1919
.from('channels')
2020
.select('*')
2121
.eq('server_id', serverId)
22+
.order('is_media', { ascending: true })
2223
.returns<Channel>();
2324
}
2425

0 commit comments

Comments
 (0)