Skip to content

Commit

Permalink
Support server side rendered ads
Browse files Browse the repository at this point in the history
Fixes #2035
  • Loading branch information
ajayyy committed Jun 22, 2024
1 parent 5c279d8 commit 4bbd59b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 69 deletions.
2 changes: 1 addition & 1 deletion maze-utils
4 changes: 2 additions & 2 deletions src/components/SkipNoticeComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { downvoteButtonColor, SkipNoticeAction } from "../utils/noticeUtils";
import { generateUserID } from "../../maze-utils/src/setup";
import { keybindToString } from "../../maze-utils/src/config";
import { getFormattedTime } from "../../maze-utils/src/formating";
import { getVideo } from "../../maze-utils/src/video";
import { getCurrentTime, getVideo } from "../../maze-utils/src/video";

enum SkipButtonState {
Undo, // Unskip
Expand Down Expand Up @@ -686,7 +686,7 @@ class SkipNoticeComponent extends React.Component<SkipNoticeProps, SkipNoticeSta
getFullDurationCountdown(index: number): () => number {
return () => {
const sponsorTime = this.segments[index];
const duration = Math.round((sponsorTime.segment[1] - getVideo().currentTime) * (1 / getVideo().playbackRate));
const duration = Math.round((sponsorTime.segment[1] - getCurrentTime()) * (1 / getVideo().playbackRate));

return Math.max(duration, Config.config.skipNoticeDuration);
};
Expand Down
8 changes: 4 additions & 4 deletions src/components/SponsorTimeEditComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { DEFAULT_CATEGORY } from "../utils/categoryUtils";
import { getFormattedTime, getFormattedTimeToSeconds } from "../../maze-utils/src/formating";
import { asyncRequestToServer } from "../utils/requests";
import { defaultPreviewTime } from "../utils/constants";
import { getVideo } from "../../maze-utils/src/video";
import { getVideo, getVideoDuration } from "../../maze-utils/src/video";

export interface SponsorTimeEditProps {
index: number;
Expand Down Expand Up @@ -402,7 +402,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
checkToShowFullVideoWarning(): void {
const sponsorTime = this.props.contentContainer().sponsorTimesSubmitting[this.props.index];
const segmentDuration = sponsorTime.segment[1] - sponsorTime.segment[0];
const videoPercentage = segmentDuration / getVideo().duration;
const videoPercentage = segmentDuration / getVideoDuration();

if (videoPercentage > 0.6 && !this.fullVideoWarningShown
&& (sponsorTime.category === "sponsor" || sponsorTime.category === "selfpromo" || sponsorTime.category === "chooseACategory")) {
Expand Down Expand Up @@ -554,7 +554,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
}

setTimeToEnd(): void {
this.setTimeTo(1, getVideo().duration);
this.setTimeTo(1, getVideoDuration());
}

/**
Expand Down Expand Up @@ -641,7 +641,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
sponsorTimesSubmitting[this.props.index].segment[0] = startTime;
}
} else if (this.state.sponsorTimeEdits[1] === null && category === "outro" && !sponsorTimesSubmitting[this.props.index].segment[1]) {
sponsorTimesSubmitting[this.props.index].segment[1] = getVideo().duration;
sponsorTimesSubmitting[this.props.index].segment[1] = getVideoDuration();
this.props.contentContainer().updateEditButtonsOnPlayer();
}

Expand Down
Loading

0 comments on commit 4bbd59b

Please sign in to comment.