Use sdk/panel onOpen event listener
When the panel is constructed, Recommend.js's handlePanelOpen is specified as the callback function for whenever the panel opens. The telemetry logging for panel open events is done here. This way, Recommend.js does not have to keep track of the state of the panel. Closes #66
This commit is contained in:
Родитель
dccf1b7628
Коммит
4fc20345be
|
@ -19,7 +19,7 @@ class Recommender {
|
|||
constructor() {
|
||||
this.telemetryLog = new TelemetryLog();
|
||||
const methodsToBind = ['endOnboard', 'showPanel', 'waitForWindow',
|
||||
'handlePanelHide', 'hidePanel'];
|
||||
'handlePanelHide', 'handlePanelShow', 'hidePanel'];
|
||||
for (let key of methodsToBind) { // eslint-disable-line prefer-const
|
||||
this[key] = this[key].bind(this);
|
||||
}
|
||||
|
@ -72,18 +72,22 @@ class Recommender {
|
|||
height: panelRecHeight + footerHeight,
|
||||
contentURL: './recommendation/recWindow.html',
|
||||
contentScriptFile: './recommendation/notify.js',
|
||||
onShow: this.handlePanelShow,
|
||||
onHide: this.handlePanelHide,
|
||||
});
|
||||
}
|
||||
|
||||
showPanel(button) {
|
||||
this.telemetryLog.showPanel(this.activeRecDomain);
|
||||
button.handlePanelOpen();
|
||||
this.panel.show({
|
||||
position: button,
|
||||
});
|
||||
}
|
||||
|
||||
handlePanelShow() {
|
||||
this.telemetryLog.showPanel(this.activeRecDomain);
|
||||
}
|
||||
|
||||
handlePanelHide() {
|
||||
this.telemetryLog.hidePanel(this.activeRecDomain);
|
||||
const win = tabs.activeTab.window;
|
||||
|
|
Загрузка…
Ссылка в новой задаче