Skip to content

Commit

Permalink
Revert "v1.4.3"
Browse files Browse the repository at this point in the history
This reverts commit 68945e6.
  • Loading branch information
TheFrodo committed Sep 1, 2023
1 parent 3e38cdc commit 0860aea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 90 deletions.
92 changes: 22 additions & 70 deletions src/components/Vod/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
IconTrashX,
IconLock,
IconLockOpen,
IconShare,
} from "@tabler/icons";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useEffect, useRef, useState } from "react";
Expand All @@ -27,7 +26,6 @@ import { VodInfoModalContent } from "./InfoModalContent";
import { VodPlaylistModalContent } from "./PlaylistModalContent";
import { ROLES, useJsxAuth } from "../../hooks/useJsxAuth";
import AdminVodDelete from "../Admin/Vods/Delete";
import vodDataBus from "./EventBus";

const useStyles = createStyles((theme) => ({
action: {
Expand Down Expand Up @@ -76,8 +74,8 @@ export const VodMenu = ({ vod, style }: any) => {
).then(() => {
queryClient.invalidateQueries(["playback-data"]);
showNotification({
title: "Marked as Watched",
message: "VOD has been successfully marked as watched",
title: "Als gesehen markiert",
message: "VOD wurde erfolgreich als angesehen markiert",
});
});
},
Expand All @@ -96,8 +94,8 @@ export const VodMenu = ({ vod, style }: any) => {
).then(() => {
queryClient.invalidateQueries(["vod", vod.id]);
showNotification({
title: "Video Updated",
message: `Video has been ${lock ? "locked" : "unlocked"}`,
title: "Video aktualisiert",
message: `Das Video wurde ${lock ? "gesperrt" : "entsperrt"}`,
});
if (lock == true) {
isLocked.current = true;
Expand All @@ -122,8 +120,8 @@ export const VodMenu = ({ vod, style }: any) => {
).then(() => {
queryClient.invalidateQueries(["playback-data"]);
showNotification({
title: "Marked as Unwatched",
message: "VOD has been successfully marked as unwatched",
title: "Als ungesehen markiert",
message: "VOD wurde erfolgreich als ungesehen markiert",
});
});
},
Expand All @@ -137,46 +135,6 @@ export const VodMenu = ({ vod, style }: any) => {
setDeletedOpened(false);
};

const shareVideo = () => {
let shareUrl: string = "";
const url = window.location.origin;

// check if we are on a vod page
if (window.location.pathname.includes("/vods/") && window.location.pathname.includes(vod.id)) {
// get the current time
const { time } = vodDataBus.getData();
const roundedTime = Math.ceil(time);
// create the url
shareUrl = `${url}/vods/${vod.id}?t=${roundedTime}`;
} else {
// create the url
shareUrl = `${url}/vods/${vod.id}`;
}

// copy the url to the clipboard
try {
navigator.clipboard.writeText(shareUrl);

// show a notification
showNotification({
title: "Copied to Clipboard",
message: "The video url has been copied to your clipboard",
});

} catch (err) {
console.error(err);
// show a notification
showNotification({
title: "Error",
message: "The clipboard API requires HTTPS, falling back to a prompt",
color: "red",
});

// fallback to a prompt
prompt("Copy to clipboard: Ctrl+C, Enter", shareUrl);
}
}

return (
<div>
<Menu shadow="md" width={200} position="top-end" withinPortal>
Expand Down Expand Up @@ -212,49 +170,43 @@ export const VodMenu = ({ vod, style }: any) => {
onClick={() => markAsWatched.mutate()}
icon={<IconHourglassHigh size={14} />}
>
Mark as Watched
Als gesehen markieren
</Menu.Item>
<Menu.Item
onClick={() => markAsUnWatched.mutate()}
icon={<IconHourglassEmpty size={14} />}
>
Mark as Unwatched
Als nicht angesehen markieren
</Menu.Item>
{isLocked.current ? (
<Menu.Item
onClick={() => lockVod.mutate(false)}
icon={<IconLockOpen size={14} />}
>
Unlock
Entsperren
</Menu.Item>
) : (
<Menu.Item
onClick={() => lockVod.mutate(true)}
icon={<IconLock size={14} />}
>
Lock
Sperren
</Menu.Item>
)}
{useJsxAuth({
loggedIn: true,
roles: [ROLES.ADMIN],
}) && (
<Menu.Item
color="red"
onClick={() => {
openDeleteModal();
}}
icon={<IconTrashX size={14} />}
>
Delete
</Menu.Item>
)}
<Menu.Item
onClick={() => shareVideo()}
icon={<IconShare size={14} />}
>
Share
</Menu.Item>
<Menu.Item
color="red"
onClick={() => {
openDeleteModal();
}}
icon={<IconTrashX size={14} />}
>
Löschen
</Menu.Item>
)}
</Menu.Dropdown>
</Menu>
<Modal
Expand All @@ -268,14 +220,14 @@ export const VodMenu = ({ vod, style }: any) => {
opened={infoModalOpened}
onClose={() => setInfoModalOpended(false)}
size="xl"
title="VOD Information"
title="VOD Informationen"
>
<VodInfoModalContent vod={vod} />
</Modal>
<Modal
opened={deletedOpened}
onClose={() => setDeletedOpened(false)}
title="Delete Video"
title="Video Löschen"
>
<AdminVodDelete handleClose={closeDeleteModalCallback} vod={vod} />
</Modal>
Expand Down
23 changes: 3 additions & 20 deletions src/components/Vod/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import {
} from "@vidstack/react/icons";
import ReactDOM from "react-dom";
import TheaterModeIcon from "./TheaterModeIcon";
import { escapeURL } from "../../util/util";
import { useSearchParams } from 'next/navigation'

const useStyles = createStyles((theme) => ({
playerContainer: {
Expand All @@ -49,13 +47,11 @@ const NewVideoPlayer = ({ vod }: any) => {
const player = useRef<MediaPlayerElement>(null);
const playerRemote = useMediaRemote(player);

const [videoSource, setVideoSource] = useState([{ src: "", type: "" }]);
const [videoSource, setVideoSource] = useState<string>("");
const [videoType, setVideoType] = useState<string>("");
const [videoPoster, setVideoPoster] = useState<string>("");
const [videoTitle, setVideoTitle] = useState<string>("");

const searchParams = useSearchParams()

// Fetch playback data
const { data } = useQuery({
refetchOnWindowFocus: false,
Expand Down Expand Up @@ -94,20 +90,13 @@ const NewVideoPlayer = ({ vod }: any) => {
type = "application/x-mpegURL";
}

setVideoSource([
{
src: `${publicRuntimeConfig.CDN_URL}${escapeURL(vod.video_path)}`,
type: type,
},
]);
setVideoSource(`${publicRuntimeConfig.CDN_URL}${vod.video_path}`);
setVideoType(type);
setVideoTitle(vod.title);

// If thumbnail
if (vod.thumbnail_path) {
setVideoPoster(
`${publicRuntimeConfig.CDN_URL}${escapeURL(vod.video_path)}`
);
setVideoPoster(`${publicRuntimeConfig.CDN_URL}${vod.thumbnail_path}`);
}

// If captions
Expand All @@ -131,12 +120,6 @@ const NewVideoPlayer = ({ vod }: any) => {
player.current!.currentTime = data.time;
}

// Check if time is set in the url
const time = searchParams.get("t");
if (time) {
player.current!.currentTime = parseInt(time);
}

const mediaFullscreenButton = document.querySelector("media-menu");
const buttonContainer = document.createElement("div");

Expand Down

0 comments on commit 0860aea

Please sign in to comment.