Skip to content

Commit b83dbba

Browse files
committed
style: resolve code review suggestions
1 parent 670a456 commit b83dbba

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

assets/js/player.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,7 @@ player.on('timeupdate', function () {
158158
// Only update once every second
159159
let current_ts = Math.floor(player.currentTime());
160160
const last_player_time = timeupdate_last_ts;
161-
if (
162-
// Seek forward
163-
current_ts > timeupdate_last_ts ||
164-
// Seek backward
165-
current_ts < timeupdate_last_ts
166-
) timeupdate_last_ts = current_ts;
161+
if (current_ts !== timeupdate_last_ts) timeupdate_last_ts = current_ts;
167162
else return;
168163

169164
// YouTube links
@@ -198,16 +193,16 @@ player.on('timeupdate', function () {
198193
elem_iv_other.href = addCurrentTimeToURL(base_url_iv_other, domain);
199194
}
200195

201-
// Only increase time watched when the time difference is one second or the video is not already marked as watched
196+
// Only increase time watched when the time difference is one second and the video has not been marked as watched
202197
const isOneSecondDifference = current_ts - last_player_time === 1;
203198
const exceedsMarkWatchedAfterDuration = time_watched > MARK_WATCHED_AFTER_DURATION;
204199

205200
const $markWatchedAfterDuration = document.getElementById(`${STORAGE_MARK_WATCHED_AFTER_DURATION}_pref`);
206-
const markWatchedAfterDuration = $markWatchedAfterDuration.innerText === "true" ?? false;
201+
const markWatchedAfterDuration = $markWatchedAfterDuration?.innerText === "true";
207202

208203
if (!isOneSecondDifference || exceedsMarkWatchedAfterDuration || markWatchedAfterDuration === false) return;
209204

210-
time_watched += 1
205+
time_watched += 1;
211206

212207
// Check if time watched exceeds 30 seconds or the video is fully watched
213208
const absolute_video_duration = Math.floor(player.duration());
@@ -232,7 +227,7 @@ player.on('timeupdate', function () {
232227
id: video_id
233228
});
234229

235-
const url = `/watch_ajax?${params}`
230+
const url = `/watch_ajax?${params}`;
236231

237232
helpers.xhr('POST', url, { payload: `csrf_token=${csrf_token}` }, {
238233
on200: () => {

0 commit comments

Comments
 (0)