@@ -2,13 +2,11 @@ import * as React from 'react';
2
2
import cloneDeep from 'lodash/cloneDeep' ;
3
3
import { Dropdown , IDropdownOption , IDropdownProps } from 'office-ui-fabric-react/lib/Dropdown' ;
4
4
import { Async } from 'office-ui-fabric-react/lib/Utilities' ;
5
- import { Label } from 'office-ui-fabric-react/lib/Label' ;
6
- import { Spinner , SpinnerSize } from 'office-ui-fabric-react/lib/Spinner' ;
7
5
import * as telemetry from '../../common/telemetry' ;
8
6
import { ISPService } from '../../services/ISPService' ;
9
7
import { SPServiceFactory } from '../../services/SPServiceFactory' ;
10
8
import { IViewPickerProps , IViewPickerState } from './IViewPicker' ;
11
- import { ISPView , ISPViews } from "../../common/SPEntities" ;
9
+ import { ISPView } from "../../common/SPEntities" ;
12
10
import styles from './ViewPicker.module.scss' ;
13
11
14
12
// Empty view value
@@ -30,30 +28,30 @@ export class ViewPicker extends React.Component<IViewPickerProps, IViewPickerSta
30
28
this . async = new Async ( this ) ;
31
29
}
32
30
33
- public componentDidMount ( ) : void {
31
+ public async componentDidMount ( ) : Promise < void > {
34
32
// Start retrieving the list views
35
- this . loadViews ( ) ;
33
+ await this . loadViews ( ) ;
36
34
}
37
35
38
36
/**
39
37
* componentDidUpdate lifecycle hook
40
38
* @param prevProps
41
39
* @param prevState
42
40
*/
43
- public componentDidUpdate ( prevProps : IViewPickerProps , _prevState : IViewPickerState ) : void {
41
+ public async componentDidUpdate ( prevProps : IViewPickerProps , _prevState : IViewPickerState ) : Promise < void > {
44
42
if (
45
- this . props . listId !== prevProps . listId ||
43
+ this . props . listId !== prevProps . listId ||
46
44
this . props . webAbsoluteUrl !== prevProps . webAbsoluteUrl ||
47
- this . props . orderBy !== prevProps . orderBy
45
+ this . props . orderBy !== prevProps . orderBy
48
46
) {
49
- this . loadViews ( ) ;
47
+ await this . loadViews ( ) ;
50
48
}
51
49
52
50
if ( prevProps . selectedView !== this . props . selectedView ) {
53
51
this . setSelectedViews ( ) ;
54
52
}
55
53
}
56
-
54
+
57
55
/**
58
56
* Called when the component will unmount
59
57
*/
@@ -67,9 +65,9 @@ export class ViewPicker extends React.Component<IViewPickerProps, IViewPickerSta
67
65
68
66
69
67
const viewsToExclude : string [ ] = this . props . viewsToExclude || [ ] ;
70
- let options : IDropdownOption [ ] = [ ] ;
68
+ const options : IDropdownOption [ ] = [ ] ;
71
69
const service : ISPService = SPServiceFactory . createService ( this . props . context , true , 5000 , this . props . webAbsoluteUrl ) ;
72
- let results = await service . getViews (
70
+ const results = await service . getViews (
73
71
this . props . listId ,
74
72
this . props . orderBy ,
75
73
this . props . filter
@@ -108,14 +106,14 @@ export class ViewPicker extends React.Component<IViewPickerProps, IViewPickerSta
108
106
this . setState ( {
109
107
results : options
110
108
} ) ;
111
-
109
+
112
110
}
113
111
114
112
/**
115
113
* Set the currently selected views(s);
116
114
*/
117
115
private setSelectedViews ( ) : void {
118
- let _selectedView = cloneDeep ( this . props . selectedView ) ;
116
+ const _selectedView = cloneDeep ( this . props . selectedView ) ;
119
117
120
118
this . setState ( {
121
119
selectedView :_selectedView
@@ -155,7 +153,7 @@ export class ViewPicker extends React.Component<IViewPickerProps, IViewPickerSta
155
153
}
156
154
}
157
155
158
-
156
+
159
157
160
158
/**
161
159
* Renders the ViewPicker controls with Office UI Fabric
@@ -179,7 +177,7 @@ export class ViewPicker extends React.Component<IViewPickerProps, IViewPickerSta
179
177
placeholder,
180
178
onChange : this . onChange ,
181
179
} ;
182
-
180
+
183
181
if ( multiSelect ) {
184
182
dropdownProps . multiSelect = true ;
185
183
dropdownProps . selectedKeys = selectedView as string [ ] ;
@@ -194,4 +192,4 @@ export class ViewPicker extends React.Component<IViewPickerProps, IViewPickerSta
194
192
) ;
195
193
}
196
194
197
- }
195
+ }
0 commit comments