Skip to content

Commit

Permalink
Add message to inform popup about port video
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Dec 10, 2024
1 parent 7fa08da commit eee3208
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SkipButtonControlBar } from "./js-components/skipButtonControlBar";
import { Message, MessageResponse, VoteResponse } from "./messageTypes";
import { CategoryPill } from "./render/CategoryPill";
import { ChapterVote } from "./render/ChapterVote";
import { DescriptionPortPill } from "./render/DesciptionPortPill";
import { DescriptionPortPill, PortVideo } from "./render/DesciptionPortPill";
import { setMessageNotice, showMessage } from "./render/MessageNotice";
import { PlayerButton } from "./render/PlayerButton";
import SkipNotice from "./render/SkipNotice";
Expand Down Expand Up @@ -93,6 +93,8 @@ let shownSegmentFailedToFetchWarning = false;
let selectedSegment: SegmentUUID | null = null;
let previewedSegment = false;

let portVideo: PortVideo = null;

// JSON video info
let videoInfo: VideoInfo = null;
// Locked Categories in this tab, like: ["sponsor","intro","outro"]
Expand Down Expand Up @@ -246,10 +248,12 @@ function messageListener(
break;
case "isInfoFound":
//send the sponsor times along with if it's found
console.log(portVideo);
sendResponse({
found: sponsorDataFound,
status: lastResponseStatus,
sponsorTimes: sponsorTimes,
portVideo: portVideo,
time: getVideo()?.currentTime ?? 0,
});

Expand Down Expand Up @@ -1232,11 +1236,15 @@ function setupCategoryPill() {

function setupDescriptionPill() {
if (!descriptionPill) {
descriptionPill = new DescriptionPortPill(sponsorsLookup);
descriptionPill = new DescriptionPortPill(updatePortvideo, sponsorsLookup);
}
descriptionPill.setupDecription(getVideoID());
}

function updatePortvideo(newPortVideo: PortVideo) {
portVideo = newPortVideo;
}

async function sponsorsLookup(keepOldSubmissions = true, ignoreServerCache = false, forceUpdatePreviewBar = false) {
if (lookupWaiting) return;
//there is still no video here
Expand Down
2 changes: 2 additions & 0 deletions src/messageTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Message and Response Types
//

import { PortVideo } from "./render/DesciptionPortPill";
import { SegmentUUID, SponsorHideType, SponsorTime } from "./types";

interface BaseMessage {
Expand Down Expand Up @@ -86,6 +87,7 @@ export interface IsInfoFoundMessageResponse {
found: boolean;
status: number;
sponsorTimes: SponsorTime[];
portVideo: PortVideo;
time: number;
}

Expand Down
6 changes: 5 additions & 1 deletion src/render/DesciptionPortPill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ export class DescriptionPortPill {
ytbID: VideoID;
portUUID: string;
hasDescription: boolean;
updatePortvideo: (newPortVideo: PortVideo) => void;
sponsorsLookup: (keepOldSubmissions: boolean, ignoreServerCache: boolean, forceUpdatePreviewBar: boolean) => void;

inputContainer: HTMLElement;
buttonContainer: HTMLElement;
ref: React.RefObject<DescriptionPortPillComponent>;
root: Root;

constructor(sponsorsLookup: () => void) {
constructor(updatePortvideo: (newPortVideo: PortVideo) => void, sponsorsLookup: () => void) {
this.updatePortvideo = updatePortvideo;
this.sponsorsLookup = sponsorsLookup;
}

Expand Down Expand Up @@ -163,9 +165,11 @@ export class DescriptionPortPill {
if (portVideo) {
this.ytbID = portVideo.ytbID;
this.portUUID = portVideo.UUID;
this.updatePortvideo(portVideo);
} else {
this.ytbID = null;
this.portUUID = null;
this.updatePortvideo(null);
}
}

Expand Down

0 comments on commit eee3208

Please sign in to comment.