Skip to content

Commit

Permalink
feat: **secret feature**
Browse files Browse the repository at this point in the history
  • Loading branch information
LedaThemis committed Jan 14, 2024
1 parent f117e65 commit b45cccf
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 23 deletions.
7 changes: 6 additions & 1 deletion src/components/Application/VideoSection/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Ref, h } from 'preact';
import styles from '../../../styles/Application/index.module.scss';
import { IParty, IVideo } from 'src/utils/interfaces';
import { IParty, IUser, IVideo } from 'src/utils/interfaces';
import { Socket } from 'socket.io-client';
import { DefaultEventsMap } from 'socket.io/dist/typed-events';
import { MutableRef, useEffect, useState } from 'preact/hooks';
Expand All @@ -10,11 +10,13 @@ export function VideoSection({
party,
video,
video_ref,
user,
}: {
socket: Socket<DefaultEventsMap, DefaultEventsMap>;
party?: IParty;
video?: IVideo['data'];
video_ref: MutableRef<HTMLVideoElement | undefined>;
user?: IUser
}) {
function debounce(func, timeout = 300) {
let timer: any;
Expand Down Expand Up @@ -44,13 +46,15 @@ export function VideoSection({
}, []);

function pauseVideoSocket() {
if (!user?.data.user.id || user?.data.user.id > 3) return;
socket.emit(`video-manage-send`, {
partyId: party?.id,
action: `pause`,
});
}

function resumeVideoSocket() {
if (!user?.data.user.id || user?.data.user.id > 3) return;
socket.emit(`video-manage-send`, {
partyId: party?.id,
action: `resume`,
Expand All @@ -59,6 +63,7 @@ export function VideoSection({

// time in secs
function seekVideoSocket(time: number) {
if (!user?.data.user.id || user?.data.user.id > 3) return;
socket.emit(`video-manage-send`, {
partyId: party?.id,
action: `seek`,
Expand Down
18 changes: 18 additions & 0 deletions src/containers/pages/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ export function Application() {
})();
}, []);

useEffect(() => {
const refreshRate = (!user?.data.user.id || user?.data.user.id > 3) ? 10000 : 1000;

const intervalId = setInterval(() => {
(async () => {
try {
const { data: party } = (await api.parties.get(id)).data;
setParty(party);
} catch (err) {
// location.href = "/"
}
})();
}, refreshRate)

return () => clearInterval(intervalId);
}, [user?.data.user.id]);

useEffect(() => {
video_ref.current?.load();
}, [video?.url]);
Expand Down Expand Up @@ -112,6 +129,7 @@ export function Application() {
<MembersSection party={party} />
<VideoSection
socket={socket}
user={user}
party={party}
video={video}
video_ref={video_ref}
Expand Down
28 changes: 14 additions & 14 deletions src/containers/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ export function Home() {
jsx: () => h.JSX.Element;
description: string;
}[] = [
{
icon: ``,
name: `My videos`,
jsx: MyVideos,
description: `You can see all your videos here`,
},
{
icon: ``,
name: `My videos`,
jsx: MyVideos,
description: `You can see all your videos here`,
},

{
icon: ``,
name: `Explore`,
description: `Let's explore`,
jsx: Parties,
},
];
{
icon: ``,
name: `Explore`,
description: `Let's explore`,
jsx: Parties,
},
];

const [current, setCurrent] = useState(options[0]);

Expand Down Expand Up @@ -192,7 +192,7 @@ function Parties() {
<div class={styles.parties}>
{parties.map((party) => (
<div className={styles.party}>
<div>
<div style={{ flexGrow: 1, width: '100%' }}>
<img src={party.image_url} alt="" />
<div class={styles.name}>
<div class={styles.title}>{party.name}</div>
Expand Down
12 changes: 8 additions & 4 deletions src/containers/pages/Invite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ export function Invite() {
email: makeid(10) + `@gmail.com`,
password: `password`,
});
toast.success(`you will be redirected to party in 3 seconds`);
setTimeout(() => {
location.href = `/app/` + id;
}, 3000);

if (res) {
toast.success(`you will be redirected to party in 3 seconds`);
setTimeout(() => {
location.href = `/app/` + id;
}, 3000);
}

}}
type="text"
>
Expand Down
2 changes: 2 additions & 0 deletions src/styles/Application/chat.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$medium: 1000px;

.container {
width: 100%;
height: 100%;
Expand Down
22 changes: 21 additions & 1 deletion src/styles/Application/index.module.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
$medium: 1000px;

.container {
display: flex;
width: 100vw;
height: 100vh;
@media screen and (max-width: $medium) {
flex-direction: column;
overflow-y: auto;
}
}
.wrap {
display: flex;
Expand All @@ -24,11 +30,22 @@
}
}
.chat_section {
@media screen and (max-width: $medium) {
order: 1;
min-width: 100%;
min-height: 300px;
}
min-width: 522px;
background-color: #1c1c1c;
}
.video_section {
overflow-y: scroll;
@media screen and (max-width: $medium) {
order: 2;
min-height: 500px;
overflow: hidden;
min-width: 100%;
}
overflow-y: auto;
padding-bottom: 50px;
& > video {
max-height: 50vh;
Expand Down Expand Up @@ -66,6 +83,9 @@
background-color: #161616;
}
.members_section {
@media screen and (max-width: $medium) {
order: 3;
}
min-width: 305px;
padding-inline: 16px;
padding-block: 25px;
Expand Down
6 changes: 3 additions & 3 deletions src/styles/Application/index.module.scss.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
declare const classNames: {
readonly container: 'container';
readonly wrap: 'wrap';
readonly title: 'title';
readonly chat_section: 'chat_section';
readonly video_section: 'video_section';
readonly members_section: 'members_section';
readonly wrap: 'wrap';
readonly title: 'title';
readonly details: 'details';
readonly description: 'description';
readonly members_section: 'members_section';
readonly head: 'head';
readonly divider: 'divider';
readonly members: 'members';
Expand Down

0 comments on commit b45cccf

Please sign in to comment.