Skip to content

Commit 93890ae

Browse files
committed
Firing message on thumbnail dismiss
1 parent 6c46cf7 commit 93890ae

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

injected/src/features/duckplayer-native/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export const MSG_NAME_YOUTUBE_ERROR = 'onYoutubeError';
77
export const MSG_NAME_URL_CHANGE = 'onUrlChanged';
88
export const MSG_NAME_FEATURE_READY = 'onDuckPlayerFeatureReady';
99
export const MSG_NAME_SCRIPTS_READY = 'onDuckPlayerScriptsReady';
10+
export const MSG_NAME_DISMISS_OVERLAY = 'didDismissOverlay';

injected/src/features/duckplayer-native/duckplayer-native.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { pollTimestamp } from './get-current-timestamp.js';
22
import { muteAudio } from './mute-audio.js';
33
import { serpNotify } from './serp-notify.js';
44
import { ErrorDetection } from './error-detection.js';
5-
import { appendThumbnailOverlay } from './overlays/thumbnail-overlay.js';
5+
import { appendThumbnailOverlay as showThumbnailOverlay } from './overlays/thumbnail-overlay.js';
66
import { stopVideoFromPlaying } from './pause-video.js';
77
import { showError } from './custom-error/custom-error.js';
88
import { Logger, SideEffects } from './util.js';
@@ -122,12 +122,14 @@ export function setupDuckPlayerForYouTube(selectors, playbackPaused, environment
122122
if (targetElement) {
123123
if (pause) {
124124
sideEffects.add('stopping video from playing', () => stopVideoFromPlaying(videoElement));
125-
sideEffects.add('appending thumbnail', () =>
126-
appendThumbnailOverlay(/** @type {HTMLElement} */ (targetElement), environment, () => {
125+
sideEffects.add('appending thumbnail', () => {
126+
const clickHandler = () => {
127+
messages.notifyOverlayDismissed();
127128
sideEffects.destroy('stopping video from playing');
128129
sideEffects.destroy('appending thumbnail');
129-
}),
130-
);
130+
};
131+
return showThumbnailOverlay(/** @type {HTMLElement} */ (targetElement), environment, clickHandler);
132+
});
131133
} else {
132134
sideEffects.destroy('stopping video from playing');
133135
sideEffects.destroy('appending thumbnail');

injected/src/features/duckplayer-native/messages.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,23 @@ export class DuckPlayerNativeMessages {
100100
* Notifies browser that the feature is ready
101101
*/
102102
notifyFeatureIsReady() {
103-
console.log('FIRING', constants.MSG_NAME_FEATURE_READY);
103+
console.log('FIRING', constants.MSG_NAME_FEATURE_READY); // TODO: Remove
104104
this.messaging.notify(constants.MSG_NAME_FEATURE_READY, {});
105105
}
106106

107107
/**
108108
* Notifies browser that scripts are ready to be acalled
109109
*/
110110
notifyScriptIsReady() {
111-
console.log('FIRING', constants.MSG_NAME_SCRIPTS_READY);
111+
console.log('FIRING', constants.MSG_NAME_SCRIPTS_READY); // TODO: Remove
112112
this.messaging.notify(constants.MSG_NAME_SCRIPTS_READY, {});
113113
}
114+
115+
/**
116+
* Notifies browser that the overlay was dismissed
117+
*/
118+
notifyOverlayDismissed() {
119+
console.log('FIRING', constants.MSG_NAME_DISMISS_OVERLAY); // TODO: Remove
120+
this.messaging.notify(constants.MSG_NAME_DISMISS_OVERLAY, {});
121+
}
114122
}

0 commit comments

Comments
 (0)