Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add exact check for language and kind, referring docs #321

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/components/CourseCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export const CourseCard = ({
<div className="relative">
{course.totalVideos !== undefined &&
course.totalVideosWatched !== undefined && (
<PercentageComplete
percent={Math.ceil(
(course.totalVideosWatched / course.totalVideos) * 100,
)}
/>
)}
<PercentageComplete
percent={Math.ceil(
(course.totalVideosWatched / course.totalVideos) * 100,
)}
/>
)}
</div>
<img src={course.imageUrl} alt={course.title} className="rounded-md" />
<div className="p-2">
Expand Down
12 changes: 6 additions & 6 deletions src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,16 @@ export function ToggleButton({
<span
className={`dark:bg-white bg-black block transition-all duration-300 ease-out
h-0.5 w-6 rounded-sm my-0.5 ${
!sidebarOpen ? 'opacity-0' : 'opacity-100'
}`}
!sidebarOpen ? 'opacity-0' : 'opacity-100'
}`}
></span>
<span
className={`dark:bg-white bg-black block transition-all duration-300 ease-out
h-0.5 w-6 rounded-sm ${
!sidebarOpen
? '-rotate-45 -translate-y-1'
: 'translate-y-0.5'
}`}
!sidebarOpen
? '-rotate-45 -translate-y-1'
: 'translate-y-0.5'
}`}
></span>
</button>
);
Expand Down
30 changes: 15 additions & 15 deletions src/components/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ export const VideoPlayer = ({
}
const handleKeyPress = (event: any) => {
switch (event.code) {
case 'Space': // Space bar for play/pause
if (player.paused()) {
player.play();
case 'Space': // Space bar for play/pause
if (player.paused()) {
player.play();
event.stopPropagation();
} else {
player.pause();
event.stopPropagation();
}
break;
case 'ArrowRight': // Right arrow for seeking forward 5 seconds
player.currentTime(player.currentTime() + 5);
event.stopPropagation();
} else {
player.pause();
break;
case 'ArrowLeft': // Left arrow for seeking backward 5 seconds
player.currentTime(player.currentTime() - 5);
event.stopPropagation();
}
break;
case 'ArrowRight': // Right arrow for seeking forward 5 seconds
player.currentTime(player.currentTime() + 5);
event.stopPropagation();
break;
case 'ArrowLeft': // Left arrow for seeking backward 5 seconds
player.currentTime(player.currentTime() - 5);
event.stopPropagation();
break;
break;
}
};

Expand Down
185 changes: 95 additions & 90 deletions src/components/VideoPlayer2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
let volumeSetTimeout: ReturnType<typeof setInterval> | null = null;
const handleKeyPress = (event: any) => {
const isShiftPressed = event.shiftKey;
const tracks: TextTrackList = player.textTracks();
if (isShiftPressed) {
const currentIndexPeriod: number = PLAYBACK_RATES.indexOf(
player.playbackRate(),
Expand All @@ -77,40 +78,40 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
const newIndexDown =
currentIndexDown !== 0 ? currentIndexDown - 1 : currentIndexDown;
switch (event.code) {
case 'Period': // Increase playback speed
player.playbackRate(PLAYBACK_RATES[newIndexPeriod]);
event.stopPropagation();
break;
case 'Comma': // Decrease playback speed
player.playbackRate(PLAYBACK_RATES[newIndexComma]);
event.stopPropagation();
break;
case 'ArrowUp': // Increase volume
videoRef.current?.children[0].children[6].children[3].classList.add(
'vjs-hover',
);
if (volumeSetTimeout !== null) clearTimeout(volumeSetTimeout);
volumeSetTimeout = setTimeout(() => {
videoRef.current?.children[0].children[6].children[3].classList.remove(
case 'Period': // Increase playback speed
player.playbackRate(PLAYBACK_RATES[newIndexPeriod]);
event.stopPropagation();
break;
case 'Comma': // Decrease playback speed
player.playbackRate(PLAYBACK_RATES[newIndexComma]);
event.stopPropagation();
break;
case 'ArrowUp': // Increase volume
videoRef.current?.children[0].children[6].children[3].classList.add(
'vjs-hover',
);
}, 1000);
player.volume(VOLUME_LEVELS[newIndexUp]);
event.stopPropagation();
break;
case 'ArrowDown': // Decrease volume
videoRef.current?.children[0].children[6].children[3].classList.add(
'vjs-hover',
);
if (volumeSetTimeout !== null) clearTimeout(volumeSetTimeout);
volumeSetTimeout = setTimeout(() => {
videoRef.current?.children[0].children[6].children[3].classList.remove(
if (volumeSetTimeout !== null) clearTimeout(volumeSetTimeout);
volumeSetTimeout = setTimeout(() => {
videoRef.current?.children[0].children[6].children[3].classList.remove(
'vjs-hover',
);
}, 1000);
player.volume(VOLUME_LEVELS[newIndexUp]);
event.stopPropagation();
break;
case 'ArrowDown': // Decrease volume
videoRef.current?.children[0].children[6].children[3].classList.add(
'vjs-hover',
);
}, 1000);
player.volume(VOLUME_LEVELS[newIndexDown]);
event.stopPropagation();
break;
if (volumeSetTimeout !== null) clearTimeout(volumeSetTimeout);
volumeSetTimeout = setTimeout(() => {
videoRef.current?.children[0].children[6].children[3].classList.remove(
'vjs-hover',
);
}, 1000);
player.volume(VOLUME_LEVELS[newIndexDown]);
event.stopPropagation();
break;
}
} else if (event.code === 'KeyT') {
player.playbackRate(2);
Expand All @@ -126,70 +127,74 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
return; // Do nothing if the active element is an input or textarea
}
switch (event.code) {
case 'Space': // Space bar for play/pause
if (player.paused()) {
player.play();
case 'Space': // Space bar for play/pause
if (player.paused()) {
player.play();
event.stopPropagation();
} else {
player.pause();
event.stopPropagation();
}
event.preventDefault();
break;
case 'ArrowRight': // Right arrow for seeking forward 5 seconds
player.currentTime(player.currentTime() + 5);
event.stopPropagation();
} else {
player.pause();
break;
case 'ArrowLeft': // Left arrow for seeking backward 5 seconds
player.currentTime(player.currentTime() - 5);
event.stopPropagation();
}
event.preventDefault();
break;
case 'ArrowRight': // Right arrow for seeking forward 5 seconds
player.currentTime(player.currentTime() + 5);
event.stopPropagation();
break;
case 'ArrowLeft': // Left arrow for seeking backward 5 seconds
player.currentTime(player.currentTime() - 5);
event.stopPropagation();
break;
case 'KeyF': // F key for fullscreen
if (player.isFullscreen_) document.exitFullscreen();
else player.requestFullscreen();
event.stopPropagation();
break;
case 'KeyR': // 'R' key to restart playback from the beginning
player.currentTime(0);
event.stopPropagation();
break;
case 'KeyM': // 'M' key to toggle mute/unmute
if (player.volume() === 0) {
player.volume(1);
} else {
player.volume(0);
}
event.stopPropagation();
break;
case 'KeyK': // 'K' key for play/pause toggle
if (player.paused()) {
player.play();
} else {
player.pause();
}
event.stopPropagation();
break;
case 'KeyJ': // 'J' key for seeking backward 10 seconds multiplied by the playback rate
player.currentTime(
player.currentTime() - 10 * player.playbackRate(),
);
event.stopPropagation();
break;
case 'KeyL': // 'L' key for seeking forward 10 seconds multiplied by the playback rate
player.currentTime(
player.currentTime() + 10 * player.playbackRate(),
);
event.stopPropagation();
break;
case 'KeyC':
if (subtitles && player.textTracks().length) {
if (player.textTracks()[0].mode === 'showing') {
player.textTracks()[0].mode = 'hidden';
break;
case 'KeyF': // F key for fullscreen
if (player.isFullscreen_) document.exitFullscreen();
else player.requestFullscreen();
event.stopPropagation();
break;
case 'KeyR': // 'R' key to restart playback from the beginning
player.currentTime(0);
event.stopPropagation();
break;
case 'KeyM': // 'M' key to toggle mute/unmute
if (player.volume() === 0) {
player.volume(1);
} else {
player.textTracks()[0].mode = 'showing';
player.volume(0);
}
}
break;
event.stopPropagation();
break;
case 'KeyK': // 'K' key for play/pause toggle
if (player.paused()) {
player.play();
} else {
player.pause();
}
event.stopPropagation();
break;
case 'KeyJ': // 'J' key for seeking backward 10 seconds multiplied by the playback rate
player.currentTime(
player.currentTime() - 10 * player.playbackRate(),
);
event.stopPropagation();
break;
case 'KeyL': // 'L' key for seeking forward 10 seconds multiplied by the playback rate
player.currentTime(
player.currentTime() + 10 * player.playbackRate(),
);
event.stopPropagation();
break;
case 'KeyC':
for (let i = 0; i < tracks.length; i++) {
const track = tracks[i];

if (track.kind === 'subtitles' && track.language === 'en') {
if (track.mode === 'hidden') {
track.mode = 'showing';
} else {
track.mode = 'hidden';
}
}
}
break;
}
}
};
Expand Down
12 changes: 6 additions & 6 deletions src/components/bookmark/BookmarkView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ const BookmarkView = ({
{bookmarkData === null ||
'error' in bookmarkData ||
!bookmarkData.length ? (
<div className="flex mt-64">
<div className="m-auto">No bookmark added yet!</div>
</div>
) : (
<BookmarkList bookmarkData={bookmarkData} />
)}
<div className="flex mt-64">
<div className="m-auto">No bookmark added yet!</div>
</div>
) : (
<BookmarkList bookmarkData={bookmarkData} />
)}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ export const whyUs: TwhyUs = [
tagline: 'Assignments',
headline: 'Learn by doing',
description:
'Harkirat personally creates assignments after every lecture, so it\'s extremely hands on.',
"Harkirat personally creates assignments after every lecture, so it's extremely hands on.",
},
];
18 changes: 9 additions & 9 deletions src/db/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function getAllCoursesAndContentHierarchy(): Promise<
contentId: number;
}[];
}[]
> {
> {
const value = await Cache.getInstance().get(
'getAllCoursesAndContentHierarchy',
[],
Expand Down Expand Up @@ -100,7 +100,7 @@ export async function getAllVideos(): Promise<
createdAt: Date;
notionMetadataId: number | null;
}[]
> {
> {
const value = await Cache.getInstance().get('getAllVideos', []);
if (value) {
return value;
Expand Down Expand Up @@ -252,13 +252,13 @@ export const getFullCourseContent = async (courseId: number) => {
videoProgress:
content.type === 'video'
? {
duration: videoProgress.find((x) => x.contentId === content.id)
?.currentTimestamp,
markAsCompleted: videoProgress.find(
(x) => x.contentId === content.id,
)?.markAsCompleted,
videoFullDuration: content.VideoMetadata?.duration,
}
duration: videoProgress.find((x) => x.contentId === content.id)
?.currentTimestamp,
markAsCompleted: videoProgress.find(
(x) => x.contentId === content.id,
)?.markAsCompleted,
videoFullDuration: content.VideoMetadata?.duration,
}
: null,
},
]),
Expand Down
22 changes: 11 additions & 11 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,17 @@ export const constructCommentPrismaQuery = (

let orderBy: Prisma.Enumerable<Prisma.CommentOrderByWithRelationInput> = {};
switch (commentfilter) {
case CommentFilter.mu:
orderBy = { upvotes: 'desc' };
break;
case CommentFilter.md:
orderBy = { downvotes: 'desc' };
break;
case CommentFilter.mr:
orderBy = { createdAt: 'desc' };
break;
default:
orderBy = { upvotes: 'desc' };
case CommentFilter.mu:
orderBy = { upvotes: 'desc' };
break;
case CommentFilter.md:
orderBy = { downvotes: 'desc' };
break;
case CommentFilter.mr:
orderBy = { createdAt: 'desc' };
break;
default:
orderBy = { upvotes: 'desc' };
}

const where: Prisma.CommentWhereInput = {};
Expand Down
Loading