Skip to content

Commit 5ee5bce

Browse files
authored
Point release with fix for survey prompt (#4113)
1 parent 89723c7 commit 5ee5bce

File tree

6 files changed

+33
-17
lines changed

6 files changed

+33
-17
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
4+
## 2020.11.3 (03 December 2020)
5+
6+
### Fixes
7+
8+
1. Display survey prompt once per session.
9+
([#4077](https://github.com/Microsoft/vscode-jupyter/issues/4077))
10+
311
## 2020.11.2 (30 November 2020)
412

513
### Fixes

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jupyter",
33
"displayName": "Jupyter",
4-
"version": "2020.11.2",
4+
"version": "2020.11.3",
55
"description": "Jupyter notebook support, interactive programming and computing that supports Intellisense, debugging and more.",
66
"featureFlags": {
77
"usingNewInterpreterStorage": true

src/client/datascience/dataScienceSurveyBanner.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,12 @@ export class DataScienceSurveyBanner implements IJupyterExtensionBanner {
136136
}
137137
const executionCount: number = this.getExecutionCount();
138138
const notebookCount: number = this.getOpenNotebookCount();
139-
const show = await this.shouldShowBanner(executionCount, notebookCount);
139+
const show = this.shouldShowBanner(executionCount, notebookCount);
140140
if (!show) {
141141
return;
142142
}
143-
143+
// Disable for the current session.
144+
this.disabledInCurrentSession = true;
144145
const response = await this.appShell.showInformationMessage(this.bannerMessage, ...this.bannerLabels);
145146
switch (response) {
146147
case this.bannerLabels[DSSurveyLabelIndex.Yes]: {
@@ -154,14 +155,11 @@ export class DataScienceSurveyBanner implements IJupyterExtensionBanner {
154155
await this.disable(3);
155156
break;
156157
}
157-
default: {
158-
// Disable for the current session.
159-
this.disabledInCurrentSession = true;
160-
}
158+
default:
161159
}
162160
}
163161

164-
public async shouldShowBanner(executionCount: number, notebookOpenCount: number): Promise<boolean> {
162+
public shouldShowBanner(executionCount: number, notebookOpenCount: number) {
165163
if (!this.enabled || this.disabledInCurrentSession) {
166164
return false;
167165
}

src/client/datascience/insidersNativeNotebookSurveyBanner.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@ export class InsidersNativeNotebooksSurveyBanner implements IJupyterExtensionBan
8585
}
8686

8787
public async showBanner(): Promise<void> {
88+
if (this.disabledInCurrentSession) {
89+
return;
90+
}
91+
// Disable for the current session.
92+
this.disabledInCurrentSession = true;
8893
const executionCount: number = this.getExecutionCount();
8994
const notebookCount: number = this.getOpenNotebookCount();
9095
const show = await this.shouldShowBanner(executionCount, notebookCount);
9196
if (!show) {
9297
return;
9398
}
94-
9599
const response = await this.appShell.showInformationMessage(this.bannerMessage, ...this.bannerLabels);
96100
switch (response) {
97101
case this.bannerLabels[DSSurveyLabelIndex.Yes]: {
@@ -105,15 +109,12 @@ export class InsidersNativeNotebooksSurveyBanner implements IJupyterExtensionBan
105109
await this.disable(3);
106110
break;
107111
}
108-
default: {
109-
// Disable for the current session.
110-
this.disabledInCurrentSession = true;
111-
}
112+
default:
112113
}
113114
}
114115

115116
public async shouldShowBanner(executionCount: number, notebookOpenCount: number): Promise<boolean> {
116-
if (!this.enabled || this.disabledInCurrentSession) {
117+
if (!this.enabled) {
117118
return false;
118119
}
119120

src/test/datascience/datascienceSurveyBanner.vscode.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,17 @@ suite('DataScience Survey Banner', () => {
7474
persistentStateFactory.createGlobalPersistentState(DSSurveyStateKeys.ShowBanner, anything(), anything())
7575
).thenReturn(showBannerState);
7676

77-
bannerService = new DataScienceSurveyBanner(
77+
bannerService = createBannerService();
78+
});
79+
function createBannerService() {
80+
return new DataScienceSurveyBanner(
7881
instance(appShell),
7982
instance(persistentStateFactory),
8083
instance(browser),
8184
instance(editorProvider),
8285
instance(appEnv)
8386
);
84-
});
87+
}
8588
test('Confirm prompt is displayed & only once per session', async () => {
8689
when(appShell.showInformationMessage(anything(), anything(), anything())).thenResolve();
8790
await showBannerState.updateValue({ data: true });
@@ -106,18 +109,21 @@ suite('DataScience Survey Banner', () => {
106109
resetCalls(appShell);
107110

108111
// Attempt to display again & it won't.
112+
bannerService = createBannerService();
109113
await bannerService.showBanner();
110114
verify(browser.launch(anything())).never();
111115
verify(appShell.showInformationMessage(anything(), anything(), anything())).never();
112116

113117
// Advance time by 1 month & still not displayed.
114118
clock.tick(MillisecondsInADay * 30);
119+
bannerService = createBannerService();
115120
await bannerService.showBanner();
116121
verify(browser.launch(anything())).never();
117122
verify(appShell.showInformationMessage(anything(), anything(), anything())).never();
118123

119124
// Advance time by 3.5 month & it will be displayed.
120125
clock.tick(MillisecondsInADay * 30 * 3.5);
126+
bannerService = createBannerService();
121127
await bannerService.showBanner();
122128
verify(browser.launch(anything())).never();
123129
verify(appShell.showInformationMessage(anything(), anything(), anything())).once();
@@ -137,12 +143,14 @@ suite('DataScience Survey Banner', () => {
137143
resetCalls(appShell);
138144

139145
// Attempt to display again & it won't.
146+
bannerService = createBannerService();
140147
await bannerService.showBanner();
141148
verify(browser.launch(anything())).never();
142149
verify(appShell.showInformationMessage(anything(), anything(), anything())).never();
143150

144151
// Advance time by 1 month & still not displayed.
145152
clock.tick(MillisecondsInADay * 30);
153+
bannerService = createBannerService();
146154
await bannerService.showBanner();
147155
verify(browser.launch(anything())).never();
148156
verify(appShell.showInformationMessage(anything(), anything(), anything())).never();
@@ -152,6 +160,7 @@ suite('DataScience Survey Banner', () => {
152160
when(appShell.showInformationMessage(anything(), anything(), anything())).thenResolve(
153161
localize.DataScienceSurveyBanner.bannerLabelNo() as any
154162
);
163+
bannerService = createBannerService();
155164
await bannerService.showBanner();
156165
verify(browser.launch(anything())).never();
157166
verify(appShell.showInformationMessage(anything(), anything(), anything())).once();

0 commit comments

Comments
 (0)